linking stuff

This commit is contained in:
Jake Kasper
2025-08-25 08:42:03 -04:00
parent b1dba9e6d7
commit 88996a8f5b
5 changed files with 192 additions and 14 deletions

View File

@@ -91,8 +91,10 @@ const userProductSchema = Joi.object({
// Spreader settings for granular products
spreaderSettings: Joi.array().items(
Joi.object({
id: Joi.number().optional(), // For frontend temporary IDs
spreaderBrand: Joi.string().max(100).required(),
id: Joi.number().optional(), // For existing settings
equipmentId: Joi.number().integer().positive().optional(), // Link to user_equipment
// Legacy fields for backward compatibility
spreaderBrand: Joi.string().max(100).optional(),
spreaderModel: Joi.alternatives().try(
Joi.string().max(100).allow(''),
Joi.allow(null)
@@ -106,7 +108,7 @@ const userProductSchema = Joi.object({
Joi.string().allow(''),
Joi.allow(null)
).optional()
})
}).or('equipmentId', 'spreaderBrand') // Must have either equipment reference or brand
).optional()
});