Interface: FormProviderProps<VS, SD, ES, WS>
Type parameters#
| Name | Type | Description |
|---|---|---|
VS | VS | Type of form value state. |
SD | unknown | Type of submit handler result. |
ES | undefined | Type of form error state. |
WS | undefined | Type of form warning state. |
Hierarchy#
FormOptions<VS,SD,ES,WS>RefAttributes<FormState<VS,SD,ES,WS>>↳
FormProviderProps
Properties#
children#
• Optional children: ReactNode | (form: FormState<VS, SD, ES, WS>) => null | ReactElement<any, string | JSXElementConstructor<any>>
onSubmit#
• onSubmit: SubmitHandler<VS, SD, ES>
This handler is triggered by a call to the FormState.submit method if all fields are currently valid and returns a submit result representing either a successful submit or a {@link SubmitError | submit error}.
const options = { async onSubmit(values) { // process submit event... return {ok: true, data: ...}; },};Return async submit validation errors as a failed submit result, not as a thrown error or rejected promise.
SyntaxError: No-Inline evaluations must call `render`.
Inherited from#
validate#
• Optional validate: ValidateHandler<VS, ES>
Run error validation on the entire value state. This handler is triggered when a FormState instance is first initialized and every time the value state changes. The return value is an object that matches the structure of the form value state where any non-empty value at the same path as a field is considered an error.
const options = { ... validate(values) { const errors {}; // process validation... return errors; },};Inherited from#
values#
• values: VS
warn#
• Optional warn: ValidateHandler<VS, WS>
Use this handler to process soft validation "errors" that should not block a submit event. This handler otherwise has identical behavior to FormOptions.validate.
const options = { ... warn(values) { const warnings {}; // process validation... return warnings; },};