// #region Imports
// #endregion
const minAttribute = 'min';
/**
 * Validator that requires the control's value to be greater than or equal to the provided number.
 *
 * State:
 * * rangeUnderflow
 *
 * @public
 * @param element
 * @returns null if the validation check passes, otherwise an object containing information.
 */
export function minValidator(element) {
    if (!element.hasAttribute(minAttribute)) {
        console.warn(`[MinValidator]: The '${minAttribute}' attribute of '${element.tagName.toLowerCase()}' is missing in the inner form field element.`);
    }
    if (isEmptyInputValue(element.value) || isEmptyInputValue(element.min)) {
        return null; // don't validate empty values to allow optional controls
    }
    const value = parseFloat(element.value);
    // Controls with NaN values after parsing should be treated as not having a
    // minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
    return !isNaN(value) && value < element.min
        ? {
            rangeUnderflow: [true, {
                    min: element.min,
                    actual: element.value
                }]
        }
        : null;
}
function isEmptyInputValue(value) {
    return value == null || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0);
}
//# sourceMappingURL=MinElementValidatorFn.js.map