UNPKG

react-fatless-form

Version:

A lightweight React form package designed for simplicity that simplifies form handling and validation without unnecessary complexity or bloat.

28 lines (27 loc) 1.03 kB
import * as yup from "yup"; /** * Creates a Yup-based resolver for handleSubmit. * Maintains backward compatibility for existing Yup users. * * @template T - Form value type * @param {yup.ObjectSchema<T>} schema - Yup validation schema * @param {boolean} [abortEarly=false] - Stop validation at first error * @returns {(values: T) => Partial<Record<keyof T, string>>} Resolver function * * @example * // Using with handleSubmit * import { yupResolver } from "./validation"; * * handleSubmit( * form, * yupResolver(schema), * onSubmit * ); */ export declare function yupResolver<T extends Record<string, any>>(schema: yup.ObjectSchema<T>, abortEarly?: boolean): (values: T) => Partial<Record<keyof T, string>>; /** * Generic validation helper (optional - for direct usage) * * @deprecated Prefer using resolver functions directly */ export declare function validateSchema<T extends Record<string, any>>(resolver: (values: T) => Partial<Record<keyof T, string>>, values: T): Partial<Record<keyof T, string>>;