Skip to content
Playground

State

export interface FormValidationResult<E> {
formValue: FormValue;
formErrors: FieldErrorsMap<E>;
}
export type FormSubmission<V> = Action<
[event: SubmitEvent],
FormValidationResult<AnyFormValueValidatorError<V>>,
unknown
>;
export type FieldsValidation<V> = Action<
[config: Config, value: FieldValue],
FieldError<AnyFieldValueValidatorError<V>>[],
unknown
>;
export interface FormState<T, V extends Validator> {
readonly context: FormContext;
readonly submission: FormSubmission<V>;
readonly fieldsValidation: FieldsValidation<V>;
/**
* An accessor that maintains form state consistency:
*
* - A snapshot of the form state is returned on access
* - Default values from JSON Schema are taken into account during assignment
*
* You can gain direct access to the internal state by hacking types:
*
* `(form.context as FormInternalContext<typeof validator>).value`
*/
value: T | undefined;
isSubmitted: boolean;
isChanged: boolean;
errors: FieldErrorsMap<PossibleError<V>>;
submit(e: SubmitEvent): void;
reset(e: Event): void;
}