UNPKG

@cosva-lab/form-builder

Version:
34 lines (33 loc) 1.5 kB
import { BaseField } from "../builders/BaseField.mjs"; import { FieldType, GetErrors, PropsField, Validate, ValidateField, ValidationError } from "../../types.mjs"; //#region src/utils/validate/InputValidator.d.ts type PropsInput<Type extends FieldType> = Validate<Type> & PropsField<Type>; declare abstract class InputValidator<Type extends FieldType<any, any, any>> extends BaseField<Type> { originalProps?: Pick<PropsInput<Type>, 'value' | 'validate'>; static getValidation<Field extends FieldType>(obj: InputValidator<Field>): boolean | undefined; _validate?: ValidateField<Type>; get validate(): ValidateField<Type> | undefined; set validate(validate: ValidateField<Type> | undefined); touched?: boolean; get untouched(): boolean; validations: Type['validations']; constructor(props: PropsInput<Type>); abstract getErrors(): Promise<GetErrors<Type['validations']> | undefined> | GetErrors<Type['validations']> | undefined; markAsTouched: () => void; markAsUntouched: () => void; private validityBase; /** * @description Returns true if the field is valid * @return {Promise<boolean>} */ validity(): Promise<boolean>; private _calculateStatus; updateValueAndValidity(): Promise<void>; reset(): void; addError(error: ValidationError): void; addErrors(errors: ValidationError[]): void; setError: (error: ValidationError) => void; setErrors: (errors: ValidationError[]) => void; } //#endregion export { InputValidator, InputValidator as default };