Skip to content

Commit

Permalink
Merge pull request #119 from kstolp/validate-options
Browse files Browse the repository at this point in the history
Add option for using custom Joi validation options
  • Loading branch information
aheckmann authored Apr 26, 2021
2 parents 207a409 + 8036885 commit 0aa5c45
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public.route(routes);
- `autoFields`: Determines whether form fields should be auto-parsed (default: `true`). See the [await-busboy docs](https://github.com/aheckmann/await-busboy#parts--parsestream-options).
- `output`: see [output validation](#validating-output)
- `continueOnError`: if validation fails, this flags determines if `koa-joi-router` should [continue processing](#handling-errors) the middleware stack or stop and respond with an error immediately. useful when you want your route to handle the error response. default `false`
- `validateOptions`: options for Joi validate. default `{}`
- `handler`: **required** async function or functions
- `pre`: async function or function, will be called before parser and validators
- `meta`: meta data about this route. `koa-joi-router` ignores this but stores it along with all other route data
Expand Down
2 changes: 1 addition & 1 deletion joi-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function validateInput(prop, ctx, validate) {
debug('validating %s', prop);

const request = ctx.request;
const res = Joi.compile(validate[prop]).validate(request[prop]);
const res = Joi.compile(validate[prop]).validate(request[prop], validate.validateOptions || {});

if (res.error) {
res.error.status = validate.failure;
Expand Down

0 comments on commit 0aa5c45

Please sign in to comment.