import * as yup from 'yup'; import { ObjectSchema, AnyObject, Schema } from 'yup'; /** * Type representing the Reform data structure */ export declare type ReformSchema = { groups: Array<{ data: T; }>; }; /** * Creates a Yup schema compatible with Reform's data structure * Supports multiple ways of defining schemas to match user preferences * * @template T - The type of form data * @param schemaDefinition - Schema definition in various formats * @returns Yup schema for the entire Reform structure * * @example * // Method 1: Using field-by-field schema definition * const userSchema = createReformSchema({ * name: yup.string().required(), * age: yup.number().min(18), * tags: yup.array().of(yup.string()) * }); * * @example * // Method 2: Using a pre-defined Yup object schema * const fieldSchema = yup.object({ * name: yup.string().required(), * age: yup.number().min(18) * }); * const userSchema = createReformSchema(fieldSchema); * * @example * // Method 3: Using a schema builder function * const userSchema = createReformSchema(fields => ({ * name: fields.string().required(), * email: fields.string().email(), * preferences: fields.object({ * theme: fields.string(), * notifications: fields.boolean() * }) * })); */ export declare function createReformSchema>(schemaDefinition: Record> | ObjectSchema | ((fields: typeof yup) => Record>)): ObjectSchema<{ groups: Array<{ data: T; }>; }, AnyObject, any>;