Comparing version 12.1.0 to 12.1.1
{ | ||
"name": "celebrate", | ||
"version": "12.1.0", | ||
"version": "12.1.1", | ||
"description": "A joi validation middleware for Express.", | ||
@@ -54,6 +54,3 @@ "main": "lib/index.js", | ||
"markdown-toc": "1.2.x" | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
} | ||
} |
@@ -44,3 +44,2 @@ [![celebrate](https://github.com/arb/celebrate/raw/master/images/logo.svg?sanitize=1)](https://www.npmjs.org/package/celebrate) | ||
- [express Compatibility](#express-compatibility) | ||
- [Mutation Warning](#mutation-warning) | ||
- [Example Usage](#example-usage) | ||
@@ -54,3 +53,6 @@ - [API](#api) | ||
- [`isCelebrate(err)`](#iscelebrateerr) | ||
- [Validation Order](#validation-order) | ||
- [Additional Details](#additional-details) | ||
- [Validation Order](#validation-order) | ||
- [Mutation Warning](#mutation-warning) | ||
- [Additional Info](#additional-info) | ||
- [Issues](#issues) | ||
@@ -64,8 +66,2 @@ | ||
## Mutation Warning | ||
If you use any of joi's updating validation APIs (`default`, `rename`, etc.) `celebrate` will override the source value with the changes applied by joi. | ||
For example, if you validate `req.query` and have a `default` value in your joi schema, if the incoming `req.query` is missing a value for default, during validation `celebrate` will overrite the original `req.query` with the result of `joi.validate`. This is done so that once `req` has been validated, you can be sure all the inputs are valid and ready to consume in your handler functions and you don't need to re-write all your handlers to look for the query values in `res.locals.*`. | ||
## Example Usage | ||
@@ -138,3 +134,3 @@ | ||
Errors origintating from the `celebrate()` middleware are [`CelebrateError`](#celebrateerrorerr-segment-opts) objects. | ||
Errors origintating from the `celebrate()` middleware are [`CelebrateError`](##celebrateerrorerror-segment-opts) objects. | ||
@@ -183,4 +179,6 @@ ### `Joi` | ||
## Validation Order | ||
## Additional Details | ||
### Validation Order | ||
celebrate validates request values in the following order: | ||
@@ -197,4 +195,14 @@ | ||
### Mutation Warning | ||
If you use any of joi's updating validation APIs (`default`, `rename`, etc.) `celebrate` will override the source value with the changes applied by joi. | ||
For example, if you validate `req.query` and have a `default` value in your joi schema, if the incoming `req.query` is missing a value for default, during validation `celebrate` will overrite the original `req.query` with the result of `joi.validate`. This is done so that once `req` has been validated, you can be sure all the inputs are valid and ready to consume in your handler functions and you don't need to re-write all your handlers to look for the query values in `res.locals.*`. | ||
### Additional Info | ||
According the the HTTP spec, `GET` requests should _not_ include a body in the request payload. For that reason, `celebrate` does not validate the body on `GET` requests. | ||
## Issues | ||
*Before* opening issues on this repo, make sure your joi schema is correct and working as you intended. The bulk of this code is just exposing the joi API as express middleware. All of the heavy lifting still happens inside joi. You can go [here](https://npm.runkit.com/joi) to verify your joi schema easily. |
21137
203