Skip to main content

Interface: FormProviderProps<VS, SD, ES, WS>

Type parameters#

NameTypeDescription
VSVSType of form value state.
SDunknownType of submit handler result.
ESundefinedType of form error state.
WSundefinedType of form warning state.

Hierarchy#

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.

Live Editor
Result
SyntaxError: No-Inline evaluations must call `render`.

Inherited from#

FormOptions.onSubmit


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#

FormOptions.validate


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;  },};

Inherited from#

FormOptions.warn