@42.nl/final-form-field-validation
Version:
Validating final forms.
32 lines (31 loc) • 1.21 kB
TypeScript
import { FieldValidator } from 'final-form';
import { FieldProps } from 'react-final-form';
export type Props<FieldValue, T extends HTMLElement> = FieldProps<FieldValue, T> & {
/**
* An array of custom validators to run whenever the field changes.
*/
validators?: FieldValidator<FieldValue>[];
/**
* An array of custom async validators to run whenever the field changes
* and the synchronous validators have passed.
*/
asyncValidators?: FieldValidator<FieldValue>[];
/**
* The number of milliseconds to wait before the async validators are ran
* to prevent validation requests on every keystroke.
*
* Defaults to 200 milliseconds.
*
* @type {number}
* @memberof FieldProps
*/
asyncValidatorsDebounce?: number;
};
/**
* Field wraps final-form's Field, and adds async validation.
*
* It is possible to add custom field validators and async validators
* via the `validators` and `asyncValidators` props. The `asyncValidators`
* are only ran when all synchronous `validators` pass.
*/
export declare function Field<FieldValue, T extends HTMLElement>(props: Props<FieldValue, T>): import("react/jsx-runtime").JSX.Element;