// #region Imports
// #endregion
const maxLengthAttribute = 'maxlength';
/**
 * Validator that requires the length of the control's value to be less than or equal
 * to the provided maximum length. See `Validators.maxLength` for additional information.
 *
 * State:
 * * tooLong
 *
 * @public
 * @param element
 * @returns null if the validation check passes, otherwise an object containing information.
 */
export function maxLengthValidator(element) {
    if (!element.hasAttribute(maxLengthAttribute)) {
        console.warn(`[MaxLengthValidator]: The '${maxLengthAttribute}' attribute of '${element.tagName.toLowerCase()}' is missing in the inner form field element.`);
    }
    return hasValidLength(element.value) && element.value.length > element.maxlength
        ? {
            tooLong: [true, {
                    actualLength: element.value.length,
                    maxLength: element.maxlength
                }]
        }
        : null;
}
function hasValidLength(value) {
    return value != null && typeof value.length === 'number';
}
//# sourceMappingURL=MaxLengthElementValidatorFn.js.map