I would like to convert/transform into an empty array if the value is null
but when I add the custom
method of Joi on my list
schema, it doesn't seem to pass by and the value is never converted. I'll always receive null
:
Joi.list().allow(null).custom((value) => {
if (value === null) {
return [];
}
return value;
});
Joi.list().allow(null).custom((value) => {
if (value === null) {
return [];
}
return [];
});
Both examples above doesn't work
If value === null, convert to []
Else do nothing
Thanks for your help !