validation shit
This commit is contained in:
@@ -108,7 +108,13 @@ const userProductSchema = Joi.object({
|
||||
Joi.string().allow(''),
|
||||
Joi.allow(null)
|
||||
).optional()
|
||||
}).or('equipmentId', 'spreaderBrand') // Must have either equipment reference or brand
|
||||
}).when('equipmentId', {
|
||||
is: Joi.exist(),
|
||||
then: Joi.object(), // When equipmentId exists, spreaderBrand is optional
|
||||
otherwise: Joi.object({
|
||||
spreaderBrand: Joi.string().max(100).required() // When no equipmentId, require spreaderBrand
|
||||
})
|
||||
})
|
||||
).optional()
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user