tlivings / enjoi

Converts a JSON schema to a Joi schema.
Apache License 2.0
283 stars 57 forks source link

Disallow empty string if value is required #115

Closed luka-zitnik closed 12 months ago

luka-zitnik commented 1 year ago

Joi's allow('') has been used to combat string() not accepting ''. But that seems to not be taking into account a required object property, for which an empty string as a value should mean empty the same way as an undefined.

Even if it's a matter of preference, there's no meaningful way to describe the criteria. Possibly "minLength": "x" would be a workaround.

On the other hand, it is still possible to require a prop but allow '', which has already been covered as a unit test which continues to pass.

luka-zitnik commented 12 months ago

I misunderstood "required" prop. Cancelling PR.