Skip to content

Commit

Permalink
feat: add shouldSkipValidation option
Browse files Browse the repository at this point in the history
  • Loading branch information
kperdomo1 authored Apr 14, 2023
2 parents 81a0a1b + ed5258e commit 8a9abe5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var defaultOptions = {
errorsAsArray: true,
errorHandler: false,
forbidUndefinedVariables: false,
validatorModels: {}
validatorModels: {},
shouldSkipValidation: () => false,
};

module.exports.validationPlugin = function (options) {
Expand All @@ -52,7 +53,7 @@ module.exports.validationPlugin = function (options) {
return function (req, res, next) {
var validationModel = req.route?.spec?.validation || req.route?.validation || undefined;

if (validationModel) {
if (validationModel && !options.shouldSkipValidation(req, res, next)) {
// validate
var errors = self.validation.process(validationModel, req, options);

Expand Down

0 comments on commit 8a9abe5

Please sign in to comment.