UNPKG

@shopify/react-form-state

Version:
27 lines (26 loc) 1.87 kB
interface Matcher<Input, Fields = any> { (input: Input, fields: Fields): boolean; } interface StringMapper { (input: string): any; } declare type ErrorContent = string | StringMapper; export declare function validateNested<Input extends object, Fields>(validatorDictionary: any): (input: Input, fields: Fields) => any; export declare function validateList<Input extends object, Fields>(validatorDictionary: any): (input: Input[], fields: Fields) => any[] | undefined; export declare function validateWithFields<Input, Fields>(matcher: Matcher<Input, Fields>, errorContent: ErrorContent): (input: Input, fields: Fields) => string | void | StringMapper | undefined; export declare function validate<Input>(matcher: Matcher<Input>, errorContent: ErrorContent): (input: Input) => ErrorContent | undefined | void; export declare function validateRequired<Input>(matcher: Matcher<Input>, errorContent: ErrorContent): (input: Input) => ErrorContent | undefined | void; declare const validators: { lengthMoreThan(length: number, errorContent: ErrorContent): (input: { length: number; }) => string | void | StringMapper | undefined; lengthLessThan(length: number, errorContent: ErrorContent): (input: { length: number; }) => string | void | StringMapper | undefined; numericString(errorContent: ErrorContent): (input: string) => string | void | StringMapper | undefined; positiveNumericString(errorContent: ErrorContent): (input: string) => string | void | StringMapper | undefined; nonNumericString(errorContent: ErrorContent): (input: string) => string | void | StringMapper | undefined; requiredString(errorContent: ErrorContent): (input: string) => string | void | StringMapper | undefined; required(errorContent: ErrorContent): (input: any) => string | void | StringMapper | undefined; }; export default validators;