UNPKG

@schema-render/core-react

Version:

Through a set of simple JSON Schema, efficiently build a set of forms.

34 lines (33 loc) 1.46 kB
import type { IDeepReadonly } from '../typings/common'; import type { ICore, IOpenFunctionValidatorResult, IOpenValidatorParams } from '../typings/core'; import type { IBaseSchema, IRuleItem } from '../typings/schema'; export interface IParams { value: any; rules: IBaseSchema['rules'] | IDeepReadonly<IBaseSchema['rules']>; globalValidators: ICore['validators'] | undefined; globalValidatorParams: IOpenValidatorParams | undefined; locale: Required<ICore>['locale']['validation']; } export interface IValidationError extends IOpenFunctionValidatorResult { [key: string]: any; } export declare class SchemaRulesValidator { static failUK: string | symbol; static isValidationError(err: any): err is IValidationError; static fail(data: any): never; private value; private rules; private locale; private globalValidators; private globalValidatorParams; constructor(params: IParams); setValue(value: IParams['value']): void; validate(): Promise<IOpenFunctionValidatorResult>; private validateRules; private validateRuleItem; private validateGlobal; } export declare function isValidFunctionResult(result: any): result is IOpenFunctionValidatorResult; export declare function isValidRules(rules: any): rules is IRuleItem[]; export declare function normalizeRules(rules: any): IRuleItem[]; export declare function validateRules(params: IParams): Promise<IOpenFunctionValidatorResult>;