import { NodeType, ParsedRule, NodeSubType, ValidateFn, SchemaRef, ApiErrorNode, JsonApiErrorNode, VanillaErrorNode, RequestNegotiator, ValidationContract, ValidatorResolvedConfig, ErrorReporterConstructorContract, DefaultMessagesCallback } from '../types.js'; import '../bindings/request.js'; /** * Module available methods/properties */ export declare const validator: { config: ValidatorResolvedConfig; /** * Validate is a shorthand to compile + exec. If cache * key is defined, then it will also cache the * schemas. */ validate: ValidateFn; /** * Add a new validation rule */ addRule(name: string, ruleDefinition: ValidationContract): void; /** * Add a new validation rule */ rule(name: string, validateFn: ValidationContract['validate'], compileFn?: (options: any[], type: NodeType, subtype: NodeSubType) => Partial>, restrictForTypes?: NodeSubType[]): void; /** * Type definition is set to any, since one can pass in a function or * an object that has chainable API. So there is no simple way * to guard the type definition. However, the `schema.create` * method will fail if the final outcome doesn't have `getTree` * method on it. */ addType(name: string, typeDefinition: any): void; /** * Type definition is set to any, since one can pass in a function or * an object that has chainable API. So there is no simple way * to guard the type definition. However, the `schema.create` * method will fail if the final outcome doesn't have `getTree` * method on it. */ type(name: string, typeDefinition: any): void; /** * Helpers required by the custom rules */ helpers: { getFieldValue: (field: string, root: any, tip: any) => any; resolveAbsoluteName: (field: string, otherField: string) => string; exists: (value: any) => boolean; isRef(value: any): value is SchemaRef; existsStrict: (value: any) => boolean; }; /** * Register a callback to return default messages. */ messages: (callback: DefaultMessagesCallback) => void; /** * Define a custom content negotiator */ negotiator: (callback: RequestNegotiator) => void; /** * List of bundled reporters */ reporters: { api: ErrorReporterConstructorContract<{ errors: ApiErrorNode[]; }>; jsonapi: ErrorReporterConstructorContract<{ errors: JsonApiErrorNode[]; }>; vanilla: ErrorReporterConstructorContract; }; /** * Configure validator global configuration */ configure(config: Omit): void; };