@feathersjs/schema
Version:
A common data schema definition format
23 lines (22 loc) • 1.12 kB
TypeScript
import { HookContext, NextFunction } from '@feathersjs/feathers';
import { Schema, Validator } from '../schema';
import { DataValidatorMap } from '../json-schema';
/**
* Options for {@link validateQuery}.
*/
export type ValidateQueryOptions = {
/**
* When `true` (the default), a successfully validated query marks the query
* so adapters skip their built-in operator and filter allowlist
* (`sanitizeQuery`). The schema is then the full allowlist.
*
* Set to `false` to still run adapter sanitization after schema validation
* (defense in depth). Both layers then apply: the schema must accept the
* query, and the adapter must still allow every `$` operator and filter.
*
* @default true
*/
skipSanitize?: boolean;
};
export declare const validateQuery: <H extends HookContext>(schema: Schema<any> | Validator, options?: ValidateQueryOptions) => (context: H, next?: NextFunction) => Promise<any>;
export declare const validateData: <H extends HookContext>(schema: Schema<any> | DataValidatorMap | Validator) => (context: H, next?: NextFunction) => Promise<any>;