export type ValidationFunction = ( val: any, state: S, ) => boolean | ((val: any) => boolean); export type ForceValidationState = (validationState: ValidationState) => void; export type GetAllErrors = (property: keyof S) => string[]; export type GetError = (property: keyof S) => string; export type GetFieldValid = (property: keyof S) => boolean; export type ResetValidationState = () => void; export type Validate = ( property: keyof S, value: unknown, state?: S, ) => boolean; export type ValidateAll = (state: S, keys?: (keyof S)[]) => boolean; export type ValidateCustom = (vals: CustomValidation[]) => boolean; export type ValidateIfTrue = ( property: keyof S, value: unknown, state?: S, ) => boolean; export type ValidateOnBlur = (state: S) => (event: any) => any; export type ValidateOnChange = ( onChange: (event: any) => any, state: S, ) => (event: any) => any; export interface ValidationObject { forceValidationState: ForceValidationState; getError: GetError; getAllErrors: GetAllErrors; getFieldValid: GetFieldValid; isValid: boolean; resetValidationState: ResetValidationState; validate: Validate; validateAll: ValidateAll; validateCustom: ValidateCustom; validateIfTrue: ValidateIfTrue; validateOnBlur: ValidateOnBlur; validateOnChange: ValidateOnChange; validationErrors: string[]; validationState: ValidationState; } export interface ValidationProps { errorMessage: string; validation: ValidationFunction; } export interface ValidationSchema { [key: string]: ValidationProps[]; } export interface ValidationState { [key: string]: { isValid: boolean; errors: string[]; }; } export interface CustomValidation { key: string; value: any; state?: any; }