Comparing version 7.0.0 to 7.0.1
@@ -9,3 +9,3 @@ 'use strict'; | ||
const validations = require('./schema'); | ||
const isCelebrate = Symbol('isCelebrate'); | ||
const CELEBRATED = Symbol('isCelebrate'); | ||
const DEFAULTS = { | ||
@@ -38,3 +38,3 @@ escapeHtml: true | ||
if (err) { | ||
err[isCelebrate] = true; | ||
err[CELEBRATED] = true; | ||
err._meta = { source }; | ||
@@ -53,2 +53,9 @@ return next(err); | ||
const isCelebrate = (err) => { | ||
if (err != null && typeof err === 'object') { // eslint-disable-line eqeqeq | ||
return err[CELEBRATED] || false; | ||
} | ||
return false; | ||
}; | ||
const celebrate = (schema, options) => { | ||
@@ -91,3 +98,3 @@ const result = Joi.validate(schema || {}, validations.schema); | ||
return (err, req, res, next) => { | ||
if (err[isCelebrate]) { | ||
if (isCelebrate(err)) { | ||
const error = { | ||
@@ -118,7 +125,7 @@ statusCode: 400, | ||
module.exports = { | ||
celebrate, | ||
Joi, | ||
errors | ||
errors, | ||
isCelebrate | ||
}; |
{ | ||
"name": "celebrate", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "A joi validation middleware for Express.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -86,2 +86,8 @@ ![Celebrate](https://github.com/continuationlabs/celebrate/raw/master/images/logo.png) | ||
### `isCelebrate(err)` | ||
Returns `true` if the provided `err` object originated from the `celebrate` middleware, and `false` otherwise. Useful if you want to write your own error handler for `celebrate` errors. | ||
- `err` - an error object | ||
## Order | ||
@@ -88,0 +94,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10868
144
106