@marblejs-contrib/middleware-joi
A Joi validation middleware for Marble.js.
Last updated
A Joi validation middleware for Marble.js.
Last updated
Joi is an object schema description language and validator for JavaScript objects. Using its schema language, you can validate things like:
HTTP request headers
HTTP body parameters
HTTP request query parameters
URL parameters
You can find detailed API reference for Joi schemas here.
Deprecation warning
Since version 4.0 @marblejs-contrib/middleware-joi
package is deprecated and won't be maintained anymore.
Since version 4.0, the middleware is a part of contrib packages. If you really want to use this middleware you can reach it via @marblejs-contrib/middleware-joi
.
For more advanced request or event validation purposes we highly recommend to use @marblejs/middleware-io package instead. It can better handle type inference for complex schemas.
Requires @marblejs/core
to be installed.
parameter
definition
schema
Schema
options
parameter
definition
headers
<optional> any
params
<optional> any
query
<optional> any
body
<optional> any
1. Example of using middleware on a GET route to validate query parameters:
Example above will validate each incoming request connected with foo$
Effect. The validation blueprint defines that the id
query parameter should be a number between <1..10>. If the schema requirements are not satisfied the middleware will throw an error with description what went wrong.
2. Example of validating all incoming requests:
Middleware author: Lucio Rubens
<optional> Joi.ValidationOptions
(see: )