UNPKG

@onesy/ui-react

Version:
67 lines (66 loc) 2.75 kB
import { TIsType, IOptions as IIsOptions } from '@onesy/utils/is'; import { TIsValidType, IOptions as IIsValidOptions } from '@onesy/utils/isValid'; export declare type IValidateOptions = { message?: string; uriDecode?: boolean; parse?: boolean; l?: any; }; export declare type IValidateModelValueIs = { type?: TIsType; options?: IIsOptions; }; export declare type IValidateModelValueIsValid = { type?: TIsValidType; options?: IIsValidOptions; }; export declare type IValidateModelValueMethodOptions = { form: IForm; property: string; object: IValidateModelValue; options: IValidateOptions; }; export declare type IValidateModelValueMethod = (value: any, options: IValidateModelValueMethodOptions) => Promise<any> | any; export declare type IValidateModelValueValidations = 'required' | 'is' | 'isValid' | 'of' | 'ofValid' | 'equal' | 'notEqual' | 'equalDeep' | 'notEqualDeep' | 'some' | 'in' | 'every' | 'properties' | 'notProperties' | 'min' | 'max' | 'length' | 'method'; export declare type IValidateModelMessages = { [p in IValidateModelValueValidations]?: string; }; export declare type IValidateModelValue = { name?: string; value?: any; message?: string; messages?: IValidateModelMessages; required?: boolean; is?: TIsType | TIsType[] | IValidateModelValueIs | IValidateModelValueIs[]; isValid?: TIsValidType | TIsValidType[] | IValidateModelValueIsValid | IValidateModelValueIsValid[]; of?: TIsType | TIsType[] | IValidateModelValueIs | IValidateModelValueIs[]; ofValid?: TIsValidType | TIsValidType[] | IValidateModelValueIsValid | IValidateModelValueIsValid[]; equal?: any; notEqual?: any; equalDeep?: any; notEqualDeep?: any; some?: any[]; in?: any[]; every?: any[]; properties?: string[]; notProperties?: string[]; min?: number; max?: number; length?: number; method?: IValidateModelValueMethod | IValidateModelValueMethod[]; touched?: boolean; error?: string; capitalize?: boolean; propertyNameUpdate?: (value: any) => string; }; export declare type IUseFormValues = Record<string, IValidateModelValue>; export declare type IForm = { value: any; values: IUseFormValues; valid: boolean; }; export declare type IValidateValidation = (property: IValidateModelValue, form: IForm) => void | Error | Promise<void | Error>; export declare type IValidateVales = Record<string, IValidateModelValue>; export declare const onValidateError: (options: IValidateOptions, model: IValidateModelValue, message?: any) => never; declare const validate: (model: IValidateModelValue, property: string, form: IForm, options_?: IValidateOptions) => Promise<void>; export default validate;