export class NativeValidationStrategy {
    onTouched(element) {
        return element.checkValidity();
    }
    async onValidChange(element, nativeInput, customValidators) {
        if (!nativeInput) {
            return;
        }
        const customValidity = !Object.values(await this.checkCustomValidity(customValidators, element.value)).length;
        nativeInput.setCustomValidity('');
        const nativeValidity = nativeInput.validity.valid;
        element.invalid = !(nativeValidity && customValidity);
        return !element.invalid;
    }
    /**
     * Check custom validity
     */
    async checkCustomValidity(validators, value) {
        if (!validators || !validators.length || !value) {
            return {};
        }
        const validations = await Promise.all(validators.map(async (fn) => fn(value)));
        return Object.assign({}, ...validations);
    }
}
