UNPKG

abolish

Version:

A javascript object validator.

39 lines (38 loc) 1.16 kB
import type { AbolishRule, AbolishSchema } from "./types"; import type { AV } from "./validator"; /** * Converts an array of rules (string | object)[] to one object rule * @example * const rule = Rule(['required', {min: 10, max: 20}, '!exact']) * // will return * { required: true, min: 10, max: 20, exact: false } * * @param rules * @constructor */ export declare function Rule(rules: AbolishRule): any; export type AbolishRuleTyped = string | AV | Array<string | AV>; export type AbolishSchemaTyped = Record<string, AbolishRuleTyped>; export type AbolishSchemaTypedSuper = { $strict?: string[] | boolean; $include?: string[]; [key: string]: AbolishRuleTyped | boolean | undefined; }; /** * Typed version of Rule * @param rule * @constructor */ export declare function RuleTyped(rule: AbolishRuleTyped): any; /** * Parse object value as rule * @param rules * @constructor */ export declare function Schema(rules: AbolishSchema): AbolishSchema; /** * Parse object value as rule * @param rules * @constructor */ export declare function SchemaTyped(rules: AbolishSchemaTyped | AbolishSchemaTypedSuper): AbolishSchemaTyped;