Add conditional around joiValidator schema.append
This commit is contained in:
parent
5f022e04a3
commit
7c2c4a0f94
|
@ -13,10 +13,13 @@ function validate(schema, property) {
|
||||||
params = ctx.request[property]
|
params = ctx.request[property]
|
||||||
}
|
}
|
||||||
|
|
||||||
schema = schema.append({
|
// not all schemas have the append property e.g. array schemas
|
||||||
createdAt: Joi.any().optional(),
|
if (schema.append) {
|
||||||
updatedAt: Joi.any().optional(),
|
schema = schema.append({
|
||||||
})
|
createdAt: Joi.any().optional(),
|
||||||
|
updatedAt: Joi.any().optional(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const { error } = schema.validate(params)
|
const { error } = schema.validate(params)
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -13,10 +13,13 @@ function validate(schema, property) {
|
||||||
params = ctx.request[property]
|
params = ctx.request[property]
|
||||||
}
|
}
|
||||||
|
|
||||||
schema = schema.append({
|
// not all schemas have the append property e.g. array schemas
|
||||||
createdAt: Joi.any().optional(),
|
if (schema.append) {
|
||||||
updatedAt: Joi.any().optional(),
|
schema = schema.append({
|
||||||
})
|
createdAt: Joi.any().optional(),
|
||||||
|
updatedAt: Joi.any().optional(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const { error } = schema.validate(params)
|
const { error } = schema.validate(params)
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
Loading…
Reference in New Issue