import * as Yup from "yup"; import { ObjectShape } from "yup/lib/object"; import { IYupRenderRule, IYupValidationRule, TCustomValidationFunction, TFormYupConfig, TYupSchemaType } from "./types"; interface IYupCombinedRule extends IYupRenderRule, IYupValidationRule { } export declare namespace YupHelper { /** * Constructs the entire Yup schema for frontend engine to use * @param yupSchemaConfig JSON representation of the eventual Yup schema * @param yupId Optionally assign an id to the schema for custom validation * @returns Yup schema ready to be used by FrontendEngine */ const buildSchema: (yupSchemaConfig: TFormYupConfig, yupId?: string | undefined) => Yup.ObjectSchema; /** * Creates a yupSchema for a given field * @param yupSchemaField Yup schema for individual field * @param fieldValidationConfig JSON representation of the Yup schema * @returns yupSchema corresponding to the specified validations and constraints */ const buildFieldSchema: (yupSchemaField: Yup.AnySchema, fieldValidationConfig: IYupCombinedRule[]) => Yup.AnySchema; /** * Initialises a Yup schema according to the type provided * @param type The schema type * @returns yupSchema that corresponds to the validation type */ const mapSchemaType: (type: TYupSchemaType) => import("yup/lib/object").OptionalObjectSchema> | Yup.StringSchema | Yup.NumberSchema | Yup.BooleanSchema | import("yup/lib/array").OptionalArraySchema | import("yup/lib/mixed").MixedSchema; /** * Adds Yup validation and constraints based on specified rules * @param yupSchema Yup schema that was previously created from specified validation type * @param schemaRules An array of validation rules to be mapped against validation type (e.g. a string schema might contain { maxLength: 255 }) * @returns yupSchema with added constraints and validations */ const mapRules: (yupSchema: Yup.AnySchema, schemaRules: V[]) => Yup.AnySchema; /** * Declare custom Yup schema condition * @param type The schema type * @param name Name of the condition * @param fn Validation function, it must return a boolean * @param yupId Assign the custom condition to a specific schema * @param overwrite Whether to replace if the custom validation is already exists */ const addCondition: (type: TYupSchemaType | "mixed", name: string, fn: TCustomValidationFunction, yupId?: string | undefined, overwrite?: boolean) => void; } export {};