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
In general Joi has made an attempt to stick to the RFCs as closely as possible. Sure, most cases are more conservative than the RFC "base validity", but as soon as we start arbitrarily putting additional constraints on top of the RFC we inevitably break a valid case for somebody.
That being said, perhaps there is room for some additional options to enforce host name constraints in a manner similar to .email()'s minDomainAtoms option.
I think that should be the default here, too, so we can avoid the "https://" case that is bound to take others by surprise :)
Edit: Sorry, that link didn't really illustrate my point as minDomainAtoms: 1 is passed. But isemail.validate does return false for localpart@ when no validation options are passed.
Context
What are you trying to achieve or the steps to reproduce ?
I'd like to sanity check urls that my users enter, but
Joi.string().uri()
accepts a url without a hostname at all:Which result you had ?
What did you expect ?
That a host name is required. It's not very helpful to allow "https://" in most scenarios.
None of the options for
uri
help with this.It seems like it comes down to a very liberal
regName
regexp that also allows the empty string:joi/lib/types/string/rfc3986.js
Line 149 in bc09c65
I understand that the idea behind rfc3986.js is to do a 1-to-1 translation of the URL RFC, and that
reg-name
is defined exactly like this in https://tools.ietf.org/html/rfc3986#section-3.2.2... but I'll argue that it's very rare that you want to be that liberal in a validation scenario.
The text was updated successfully, but these errors were encountered: