import { ComposibleValidatable, Validator } from './types'; /** Each key of the object is a validatable */ export declare type ValidatableMapOrArray = /** Mode: object */ { [key: string]: ComposibleValidatable; } /** Mode: array */ | ComposibleValidatable[] /** Mode: map */ | Map>; /** * Just a wrapper around the helpers for a set of FieldStates or FormStates */ export declare class FormState implements ComposibleValidatable { /** * SubItems can be any Validatable */ $: TValue; protected mode: 'object' | 'array' | 'map'; constructor( /** * SubItems can be any Validatable */ $: TValue); /** Get validatable objects from $ */ protected getValues: () => ComposibleValidatable[]; validating: boolean; protected _validators: Validator[]; validators(...validators: Validator[]): this; /** * - Re-runs validation on all fields * - returns `hasError` * - if no error also return the validated values against each key. */ validate(): Promise<{ hasError: true; } | { hasError: false; value: TValue; }>; protected _error: string | null | undefined; /** * Does any field or form have an error */ get hasError(): boolean; /** * Does any field have an error */ get hasFieldError(): boolean; /** * Does form level validation have an error */ get hasFormError(): boolean; /** * Call it when you are `reinit`ing child fields */ clearFormError(): void; /** * Error from some sub field if any */ get fieldError(): string | null | undefined; /** * Error from form if any */ get formError(): string | null | undefined; /** * The first error from any sub (if any) or form error */ get error(): string | null | undefined; /** * You should only show the form error if there are no field errors */ get showFormError(): boolean; /** * Resets all the fields in the form */ reset(): void; /** * Auto validation */ protected autoValidationEnabled: boolean; enableAutoValidation(): void; enableAutoValidationAndValidate(): Promise<{ hasError: true; } | { hasError: false; value: TValue; }>; disableAutoValidation(): void; /** * Composible field validation tracking */ validatedSubFields: ComposibleValidatable[]; /** * Composible fields (fields that work in conjuction with FormState) */ compose(): this; _on$ValidationPass: () => void; _on$Reinit: () => void; _setCompositionParent: (config: { on$ValidationPass: () => void; on$Reinit: () => void; }) => void; }