New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating a FQDN #925

Open
jsonmaur opened this Issue Jun 15, 2016 · 8 comments

Comments

Projects
None yet
7 participants
@jsonmaur

jsonmaur commented Jun 15, 2016

I need to be able to validate a fully qualified domain name (FQDN). This has a few differences in comparison to Joi.string().uri() and Joi.string().hostname(), such as it requires a valid TLD, doesn't have a schema, and can't include a path.

It doesn't necessarily have to check against a huge list of valid TLDs, but at least check for a TLD. You can see how they do it in this example from validator.js.

I'd be happy to submit a pull request for this, just lmk.

@simon-p-r

This comment has been minimized.

simon-p-r commented Jun 15, 2016

You can just use a regex to match this.

@jsonmaur

This comment has been minimized.

jsonmaur commented Jun 15, 2016

Absolutely, but that same argument could be made about any of the rules in Joi :) It's a decently complex regex and would be nice to have it abstracted.

@simon-p-r

This comment has been minimized.

simon-p-r commented Jun 15, 2016

You can try this one

@DavidTPate

This comment has been minimized.

Contributor

DavidTPate commented Jun 15, 2016

None of those actually check that the TLD is registered or anything just that it should be valid. This seems like a case where an extension could be made for Joi.

I'd be glad to help out with the Regex as I learned a ton from doing the one for joi.string().uri(). @jsonmaur do you happen to have a link to the RFC that defines what a valid FQDN is and what valid TLDs look like? That should have ABNF in it which would tell us what those look like.

@jsonmaur

This comment has been minimized.

jsonmaur commented Jun 15, 2016

@DavidTPate it's just the RFC spec for domain names: https://tools.ietf.org/html/rfc1035. I think it should be an extension if it needs to actually do a DNS lookup to validate the domain, but for my specific use-case (and probably 90% of others), I don't need to go that deep. Just need to check that it should be valid, e.g. matches the correct regex.

Maybe there should be a shallow check implemented directly into Joi.string(), and a deep check as an extension that does a DNS lookup?

@aaronjameslang

This comment has been minimized.

aaronjameslang commented Jun 11, 2018

Is this still something people would find useful if I implemented it?

@davnicwil

This comment has been minimized.

davnicwil commented Aug 15, 2018

@aaronjameslang I would find it useful, just came here looking for this 👍

@hueniverse

This comment has been minimized.

Member

hueniverse commented Nov 11, 2018

isemail already does this internally as part of the email address. Would be best to leverage that work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment