I have a bespoke table editor which is driven by data from the server. it renders a bunch of rows with Name and Quantity fields. All fields are required. The UI shows a validation summary so I'd like to include the value of the Name field in the error message of the associated Quantity field.
e.g.
Please enter a quantity for the 'Beans' field.
My Joi schema is like so:
contaminants: Joi.array().items(
Joi.object({
name: Joi.string(),
quantity: Joi.string().
.required()
.messages({ 'string.base': 'Base error', 'string.empty': 'Empty error' }),
})
})
),
How can I use the value of the Name field in the error message of the Quantity field?