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:
parent
69221ea331
commit
f062e2b37f
16
src/crud.js
16
src/crud.js
@ -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(),
|
||||||
}),
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user