UNPKG

@zarlex/ngx-accessor

Version:

This library provides an adapter to interact with Angular forms. It also provides an adapter to work with object signals and forms

29 lines (28 loc) 866 B
import { Observable } from 'rxjs'; import { ValidatorError } from '../errors/validator-error'; export type ValidatorFn = (value: any) => (boolean); export type AsyncValidatorFn = (value: any) => (Promise<boolean> | Observable<boolean>); export declare enum ValidatorId { required = "required", minLength = "minLength", maxLength = "maxLength", min = "min", max = "max", pattern = "pattern", email = "email" } export interface IValidator { id?: string; isValid: AsyncValidatorFn | ValidatorFn; async: boolean; error: (value: any) => ValidatorError; setupElement?: (el: HTMLElement) => void; } export type ValidationErrors<TProperties> = { [key in keyof TProperties]: Array<ValidatorError>; }; export interface ValidationUpdate { isValid: boolean; isValidating: boolean; errors: Array<ValidatorError>; }