custom-methods.js 324 B

12345678910111213
  1. const REQ_KEY = '_validationCustomMethods';
  2. module.exports = (req, options) => {
  3. req[REQ_KEY] = req[REQ_KEY] || {
  4. sanitizers: {},
  5. validators: {}
  6. };
  7. Object.assign(req[REQ_KEY].validators, options.customValidators);
  8. Object.assign(req[REQ_KEY].sanitizers, options.customSanitizers);
  9. return req[REQ_KEY];
  10. };