I have a property "email" that is defined like this:
email: joi.string().description('E-mail')
(so not required())
However, this object doesn't validate:
{
"email": ""
}
Is this gives the message "email is not allowed to be empty"
What can I do to have a property that's a string but that can also be an empty string? If I use joi.any() it passes, but of course I only want strings or empty strings. I also don't want to remove the empty properties before validating, because I effectively want to store an empty value in the database.
Did you try joi.string().allow('')?
My bad, I didn't see it under string but indeed it works! Thanks
Most helpful comment
Did you try
joi.string().allow('')?