/** * validators - a declarative, framework-free validation-rule library for SvForm * (and any editor). Each rule builder returns a `Validator`: a pure function * `(value, allValues?) => errorMessage | null`. Compose them per field; the form * runs them in order and shows the first failure. Parity: Smart `smart.validator` * (required / email / pattern / min / max / range / stringLength / compare ...). * * ```ts * import { rules } from '@svgrid/grid' * const field = { name: 'email', label: 'Email', rules: [rules.required(), rules.email()] } * ``` */ export type Validator = (value: any, values?: Record) => string | null | undefined; export type RuleOptions = { message?: string; }; export type CompareOp = '==' | '===' | '!=' | '<' | '<=' | '>' | '>='; /** Empty for validation purposes: null/undefined, '', or an empty array. */ export declare function isEmptyValue(v: any): boolean; /** The declarative rule builders. Every builder skips empty values (except * `required`) so optional fields validate format only when filled. */ export declare const rules: { required: (o?: RuleOptions) => Validator; email: (o?: RuleOptions) => Validator; url: (o?: RuleOptions) => Validator; zipCode: (o?: RuleOptions) => Validator; pattern: (re: RegExp, o?: RuleOptions) => Validator; numeric: (o?: RuleOptions) => Validator; integer: (o?: RuleOptions) => Validator; min: (n: number, o?: RuleOptions) => Validator; max: (n: number, o?: RuleOptions) => Validator; range: (lo: number, hi: number, o?: RuleOptions) => Validator; minLength: (n: number, o?: RuleOptions) => Validator; maxLength: (n: number, o?: RuleOptions) => Validator; stringLength: (lo: number, hi: number, o?: RuleOptions) => Validator; oneOf: (allowed: ReadonlyArray, o?: RuleOptions) => Validator; /** Compare against another field's value (cross-field): e.g. confirm password. */ compare: (otherField: string, op?: CompareOp, o?: RuleOptions) => Validator; /** Wrap an arbitrary predicate/function as a rule. */ custom: (fn: Validator) => Validator; }; /** Run a list of rules against a value; return the first error message, or null. */ export declare function runRules(value: any, ruleList: ReadonlyArray | undefined, values?: Record): string | null;