validation-chain-builders.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { ErrorMessage, FieldMessageFactory, Location } from '../base';
  2. /**
  3. * Creates a variant of `check()` that checks the given request locations.
  4. *
  5. * @example
  6. * const checkBodyAndQuery = buildCheckFunction(['body', 'query']);
  7. */
  8. export declare function buildCheckFunction(locations: Location[]): (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  9. /**
  10. * Creates a middleware/validation chain for one or more fields that may be located in
  11. * any of the following:
  12. *
  13. * - `req.body`
  14. * - `req.cookies`
  15. * - `req.headers`
  16. * - `req.params`
  17. * - `req.query`
  18. *
  19. * @param fields a string or array of field names to validate/sanitize
  20. * @param message an error message to use when failed validations don't specify a custom message.
  21. * Defaults to `Invalid Value`.
  22. */
  23. export declare const check: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  24. /**
  25. * Same as {@link check()}, but only validates `req.body`.
  26. */
  27. export declare const body: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  28. /**
  29. * Same as {@link check()}, but only validates `req.cookies`.
  30. */
  31. export declare const cookie: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  32. /**
  33. * Same as {@link check()}, but only validates `req.headers`.
  34. */
  35. export declare const header: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  36. /**
  37. * Same as {@link check()}, but only validates `req.params`.
  38. */
  39. export declare const param: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;
  40. /**
  41. * Same as {@link check()}, but only validates `req.query`.
  42. */
  43. export declare const query: (fields?: string | string[], message?: FieldMessageFactory | ErrorMessage) => import("..").ValidationChain;