joi
joi copied to clipboard
how to unset a string field when it's an empty string
For example, b is empty string filed
{
a: 'a',
b: ''
}
after validating , convert to an object which filed b is deleted
{
a: 'a'
}
you can use joi.string().empty('')
which will treat empty string the same as properties with undefined values.
see: https://joi.dev/api/?v=17.4.2#anyemptyschema