parent
7b17669c6d
commit
c94a3cb83a
@ -302,7 +302,7 @@ export const wineValidation = (data: unknown): Joi.ValidationResult =>
|
||||
style: Joi.string()
|
||||
.valid(...Object.values(WineStyle))
|
||||
.required(),
|
||||
characteristic: Joi.string().custom((value: string[], helper) => {
|
||||
characteristic: Joi.string().custom((value, helper) => {
|
||||
// return if no value
|
||||
if (!value) {
|
||||
return value
|
||||
@ -359,14 +359,12 @@ export const wineValidation = (data: unknown): Joi.ValidationResult =>
|
||||
})
|
||||
}
|
||||
|
||||
for (const characteristic of value) {
|
||||
if (!options.includes(characteristic)) {
|
||||
return helper.message({
|
||||
custom: Joi.expression(
|
||||
`"${characteristic}" is not a valid characteristic for "${wineType}" wine. Valid options are [${options.map((option) => `"${option}"`).join(', ')}]`
|
||||
)
|
||||
})
|
||||
}
|
||||
if (!options.includes(value)) {
|
||||
return helper.message({
|
||||
custom: Joi.expression(
|
||||
`"${value}" is not a valid characteristic for "${wineType}" wine. Valid options are [${options.map((option) => `"${option}"`).join(', ')}]`
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
return value
|
||||
|
Loading…
x
Reference in New Issue
Block a user