Question:
So I have some posts validation using @hapi/joi 17.1.1 and in there I have two fields: textfield and picture. Im not requring any of the fields yet still it is saying that picture is required.posts validation
Answer:
This is because you are sending the proppicture
from the FE side and it’s an empty string ''
. You should add an .allow('')
your validation picture: Joi.string().allow('')
if you want to save an empty string inside the DB or change the FE side to not send the picture
prop at all if the string is empty.If you have better answer, please add a comment about this, thank you!