UNPKG

@cosva-lab/form-builder

Version:
36 lines (35 loc) 1.96 kB
import type { Validation, ValidationFunction, value, Validate, ValidationErrors, ValidationError, PropsFieldBase, GlobalProps, ValidationsField, NameField, LabelPropsField } from '../../types'; import Field from '../builders/Field'; type PropsInput<V, Name extends NameField, Label extends LabelPropsField> = Validate<V, Name, Label> & PropsFieldBase<V, Name, Label>; export declare abstract class InputValidator<V extends value, Name extends NameField, Label extends LabelPropsField> extends Field<V, Name, Label> implements Validate<V, Name, Label> { originalProps?: Pick<PropsInput<V, Name, Label>, 'value' | 'validate'>; static getValidation<V, Name extends NameField, Label extends LabelPropsField>(obj: InputValidator<V, Name, Label>): boolean | undefined; _validate: ValidationsField<V, Name, Label>['validate']; get validate(): boolean | undefined; set validate(validate: boolean | undefined); touched?: boolean; get untouched(): boolean; validations?: (Validation | ValidationFunction<V, Name, Label>)[]; private _globalProps?; get globalProps(): GlobalProps | undefined; set globalProps(globalProps: GlobalProps | undefined); constructor(props: PropsInput<V, Name, Label>); protected hasValidationError(validation: Validation): boolean; abstract getErrors(): Promise<ValidationErrors | undefined> | ValidationErrors | 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: ValidationErrors): void; setError(error: ValidationError): void; setErrors(errors: ValidationErrors): void; } export default InputValidator;