// #region Imports
// #endregion
const minLengthAttribute = 'minlength';
/**
 * Validator that requires the length of the control's value to be greater than or equal
 *
 * State:
 * * tooShort
 *
 * @public
 */
export function minLengthValidator(element) {
    if (!element.hasAttribute(minLengthAttribute)) {
        console.warn(`[MinLengthValidator]: The '${minLengthAttribute}' attribute of '${element.tagName.toLowerCase()}' is missing in the inner form field element.`);
    }
    if (isEmptyInputValue(element.value) || !hasValidLength(element.value)) {
        // don't validate empty values to allow optional controls
        // don't validate values without `length` property
        return null;
    }
    return element.value.length < element.minlength
        ? {
            tooShort: [true, {
                    actualLength: element.value.length,
                    minLength: element.minlength
                }]
        }
        : null;
}
function isEmptyInputValue(value) {
    return value == null || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0);
}
function hasValidLength(value) {
    return value != null && typeof value.length === 'number';
}
//# sourceMappingURL=MinLengthElementValidatorFn.js.map