UNPKG

@shopify/react-form-state

Version:

Manage React forms tersely and type-safely with no magic

25 lines 1.83 kB
import { StringMapper } from './types'; interface Matcher<Input, Fields = any> { (input: Input, fields: Fields): boolean; } 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) => ErrorContent | undefined | void; 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; }) => ErrorContent | undefined | void; lengthLessThan(length: number, errorContent: ErrorContent): (input: { length: number; }) => ErrorContent | undefined | void; numericString(errorContent: ErrorContent): (input: string) => ErrorContent | undefined | void; positiveNumericString(errorContent: ErrorContent): (input: string) => ErrorContent | undefined | void; nonNumericString(errorContent: ErrorContent): (input: string) => ErrorContent | undefined | void; requiredString(errorContent: ErrorContent): (input: string) => ErrorContent | undefined | void; required(errorContent: ErrorContent): (input: any) => ErrorContent | undefined | void; }; export default validators; //# sourceMappingURL=validators.d.ts.map