export type InitialErrors<V extends Validator> =
| ValidationError<PossibleError<V>>[]
| Iterable<readonly [Id, FieldError<PossibleError<V>>[]]>;
export interface FormOptions<T, V extends Validator> {
translation: Translation;
resolver: (ctx: FormInternalContext<V>) => ResolveFieldType;
extraUiOptions?: ExtraUiOptions;
fieldsValidationMode?: FieldsValidationMode;
* @default DEFAULT_ID_PREFIX
* @default DEFAULT_ID_SEPARATOR
* @default DEFAULT_ID_PSEUDO_SEPARATOR
idPseudoSeparator?: string;
initialErrors?: InitialErrors<V>;
validationCombinator?: ActionsCombinator<[SubmitEvent], unknown>;
validationDelayedMs?: number;
validationTimeoutMs?: number;
fieldsValidationDebounceMs?: number;
* @default debounce(abortPrevious, fieldsValidationDebounceMs)
fieldsValidationCombinator?: ActionsCombinator<[Config, FormValue], unknown>;
fieldsValidationDelayedMs?: number;
fieldsValidationTimeoutMs?: number;
* The function to get the form data snapshot
* The snapshot is used to validate the form and passed to
* `onSubmit` and `onSubmitError` handlers.
* @default (ctx) => $state.snapshot(ctx.value)
getSnapshot?: (ctx: FormInternalContext<V>) => FormValue;
* Will be called when the form is submitted and form data
* Note that we rely on `validator.validateFormData` to check that the
* `formData is T`. So make sure you provide a `T` type that
* matches the validator check result.
onSubmit?: (value: T, e: SubmitEvent) => void;
* Will be called when the form is submitted and form data
errors: FieldErrorsMap<AnyFormValueValidatorError<V>>,
* Form validation error handler
* Will be called when the validation fails by a different reasons:
* - error during validation
* - validation is cancelled
onValidationFailure?: (state: FailedAction<unknown>, e: SubmitEvent) => void;
* Field validation error handler
onFieldsValidationFailure?: (
state: FailedAction<unknown>,
* Will be called when the form is reset.
onReset?: (e: Event) => void;
schedulerYield?: SchedulerYield;