Skip to content

Commit e3c8476

Browse files
committed
Add information to the README about how to deal with headers validation
1 parent 554a5a9 commit e3c8476

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [`validate(schemas, handler)`](#validateschemas-handler)
2323
- [`schemas`](#schemas)
2424
- [`schemas.body`](#schemasbody)
25+
- [`schemas.headers`](#schemasheaders)
2526
- [`schemas.query`](#schemasquery)
2627
- [`handler`](#handler)
2728

@@ -126,7 +127,7 @@ export default withJoi({
126127

127128
### `validate(schemas, handler)`
128129

129-
The `validate` function has support to check two request's fields: `query` and `body`. The first argument for this function should always be an object with the desired validation schemas.
130+
The `validate` function has support to check the following request fields: `body`, `headers` and `query`. The first argument for this function should always be an object with the desired validation schemas.
130131

131132
#### `schemas`
132133

@@ -140,6 +141,16 @@ Even if empty, this argument is required.
140141

141142
A valid `joi` schema.
142143

144+
##### `schemas.headers`
145+
146+
**Optional**
147+
148+
> Note: since most of the time you may receive more headers than expected, it is a good practice to make this
149+
> schema always support [`unknown`](https://joi.dev/api/?v=17.3.0#objectunknownallow) keys. Otherwise, the validation
150+
> will always fail.
151+
152+
A valid `joi` schema.
153+
143154
##### `schemas.query`
144155

145156
**Optional**

0 commit comments

Comments
 (0)