The next string returns error "value" is not allowed to be empty
Joi.validate('', Joi.string().optional())
Is that a normal behaviour? If yes - than how to allow empty?
Yes and it's documented https://github.com/hapijs/joi/blob/master/API.md#string.
this does not allow a null value. To do that, use any.allow(value). Or both!
check this if you want to allow empty string , by default joi not allow empty string :
Joi.validate('', Joi.string().allow(''))
it will work for you .
It works thanks ali
ask at any time.
You are welcome.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
Most helpful comment
check this if you want to allow empty string , by default joi not allow empty string :
Joi.validate('', Joi.string().allow(''))
it will work for you .