You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a string is purely whitespace (e.g. - " ") and uses string.trim, joi will return an any.invalid error instead of an any.empty error. If the value is just an empty string with no whitespace, it correctly returns any.empty.
I imagine it has to do with this line, which doesn't check for an empty string. In an earlier check (here), the empty string is accounted for.
Also, is an any.required error the expected behavior for the following case? I would expect an any.empty, since it should be defaulting to an empty string.
Agreed on the 1st report, I'll let you PR on this.
The 2nd case is a conflict between 2 conditions in your schema, it can't be required if you set a default. Fixing all those contradictions would bloat the lib so that's more of a won't fix.
When a string is purely whitespace (e.g. -
" "
) and usesstring.trim
, joi will return anany.invalid
error instead of anany.empty
error. If the value is just an empty string with no whitespace, it correctly returnsany.empty
.I imagine it has to do with this line, which doesn't check for an empty string. In an earlier check (here), the empty string is accounted for.
Also, is an
any.required
error the expected behavior for the following case? I would expect anany.empty
, since it should be defaulting to an empty string.If you'd like, I could do a fix and send over a pull request, assuming this isn't the expected behavior for either case.
The text was updated successfully, but these errors were encountered: