({ schema, method, url, httpPart })
| 9 | |
| 10 | const fastify = Fastify() |
| 11 | function validatorCompiler ({ schema, method, url, httpPart }) { |
| 12 | // Needed to extract the params part, |
| 13 | // without the JSON-schema encapsulation |
| 14 | // that is automatically added by the short |
| 15 | // form of params. |
| 16 | schema = joi.object(schema.properties) |
| 17 | |
| 18 | return validateHttpData |
| 19 | |
| 20 | function validateHttpData (data) { |
| 21 | return schema.validate(data) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | fastify.setValidatorCompiler(validatorCompiler) |
| 26 |