This commit is contained in:
Jake Kasper
2025-08-25 09:05:10 -04:00
parent fc832bc66a
commit 1acff6c440
2 changed files with 23 additions and 9 deletions

View File

@@ -17,7 +17,14 @@ const spreaderSettingSchema = Joi.object({
settingValue: Joi.string().max(20).required(),
rateDescription: Joi.string().max(200).allow(null, '').optional(),
notes: Joi.string().allow(null, '').optional()
}).xor('productId', 'userProductId').and('equipmentId', 'settingValue'); // Must have either productId or userProductId, but not both
}).xor('productId', 'userProductId')
.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
})
}); // Must have either productId or userProductId, but not both
const idParamSchema = Joi.object({
id: Joi.number().integer().positive().required()