Fix (validation) params is a plain object

If we use a Joi object here, we can't use `defaultsDeep` to extend b/c
the joi prototype won't extend cleanly. We'd need to use joi's `contact`
method, but that gets really complicated and error prone. So, just use
a plain object which is more correct anyway.

http://hapijs.com/tutorials/validation
This commit is contained in:
Joey Baker 2016-09-04 16:49:07 -07:00
parent 69221ea331
commit f062e2b37f

View File

@ -257,9 +257,9 @@ export const get = ({ server, model, prefix = '/', config }) => {
}, },
config: _.defaultsDeep(config, { config: _.defaultsDeep(config, {
validate: { validate: {
params: joi.object().keys({ params: {
id: joi.any(), id: joi.any(),
}), },
}, },
}), }),
}); });
@ -285,9 +285,9 @@ export const scope = ({ server, model, prefix = '/', config }) => {
}, },
config: _.defaultsDeep(config, { config: _.defaultsDeep(config, {
validate: { validate: {
params: joi.object().keys({ params: {
scope: joi.string().valid(...scopes), scope: joi.string().valid(...scopes),
}), },
}, },
}), }),
}); });
@ -372,9 +372,9 @@ export const destroyScope = ({ server, model, prefix = '/', config }) => {
}, },
config: _.defaultsDeep(config, { config: _.defaultsDeep(config, {
validate: { validate: {
params: joi.object().keys({ params: {
scope: joi.string().valid(...scopes), scope: joi.string().valid(...scopes),
}), },
}, },
}), }),
}); });
@ -400,9 +400,9 @@ export const update = ({ server, model, prefix = '/', config }) => {
config: _.defaultsDeep(config, { config: _.defaultsDeep(config, {
validate: { validate: {
payload: joi.object().required(), payload: joi.object().required(),
params: joi.object().keys({ params: {
id: joi.any(), id: joi.any(),
}), },
}, },
}), }),
}); });