UNPKG

mui-rff

Version:

Set of modern wrapper components to facilitate using Material UI with React Final Form

22 lines (21 loc) 1.01 kB
import { ReactNode } from 'react'; import { AnySchema as YupSchema, ValidationError as YupValidationError } from 'yup'; export type Translator = (errorObj: YupValidationError) => string | ReactNode; export interface ValidationError { [key: string]: ValidationError | string; } /** * Wraps the execution of a Yup schema to return a Promise<ValidationError> * where the key is the form field and the value is the error string. */ export declare function makeValidate<T>(validator: YupSchema<T>, translator?: Translator): (values: T) => Promise<ValidationError>; /** * Wraps the sync execution of a Yup schema to return a ValidationError * where the key is the form field and the value is the error string. */ export declare function makeValidateSync<T>(validator: YupSchema<T>, translator?: Translator): (values: T) => ValidationError; /** * Uses the spec field in the schema to get whether * the field is marked as required or not. */ export declare function makeRequired<T>(schema: YupSchema<T>): any;