-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
23 lines (22 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const buildDrySchema = require('./helpers/buildDrySchema')
const getValidator = require('./helpers/getValidator')
const getMiddleware = require('./helpers/getMiddleware')
const Types = require('./types')
module.exports = {
body: (schema, options={ allowExtraKeys: false, statusCode: 400 }) => {
const drySchema = buildDrySchema(schema)
const validator = getValidator(drySchema, options.allowExtraKeys)
return getMiddleware(validator, 'body', options.statusCode)
},
params: (schema, options={ allowExtraKeys: true, statusCode: 400 }) => {
const drySchema = buildDrySchema(schema)
const validator = getValidator(drySchema, options.allowExtraKeys)
return getMiddleware(validator, 'params', options.statusCode)
},
query: (schema, options={ allowExtraKeys: true, statusCode: 400 }) => {
const drySchema = buildDrySchema(schema)
const validator = getValidator(drySchema, options.allowExtraKeys)
return getMiddleware(validator, 'query', options.statusCode)
},
Types
}