validation-chain.d.ts 910 B

123456789101112131415161718
  1. import { Request } from '../base';
  2. import { ContextBuilder } from '../context-builder';
  3. import { Sanitizers } from './sanitizers';
  4. import { Validators } from './validators';
  5. import { ContextHandler } from './context-handler';
  6. import { ContextRunner } from './context-runner';
  7. export interface ValidationChain extends Validators<ValidationChain>, Sanitizers<ValidationChain>, ContextHandler<ValidationChain>, ContextRunner {
  8. (req: Request, res: any, next: (error?: any) => void): void;
  9. builder: ContextBuilder;
  10. }
  11. /**
  12. * A copy of `ValidationChain` where methods that would return the chain itself can return any other
  13. * value.
  14. * Useful for typing functions which accept either standard or custom validation chains.
  15. */
  16. export type ValidationChainLike = {
  17. [K in keyof ValidationChain]: ValidationChain[K] extends (...args: infer A) => ValidationChain ? (...args: A) => any : ValidationChain[K];
  18. };