Skip to content
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

Custom type that expects valid TLD #1

Open
fnando opened this issue Nov 24, 2015 · 7 comments
Open

Custom type that expects valid TLD #1

fnando opened this issue Nov 24, 2015 · 7 comments

Comments

@fnando
Copy link

fnando commented Nov 24, 2015

Right now this column type isn't that useful, because it accepts a@a as a valid e-mail address, which it is according to the spec, but is not really valid on the real world.

Would be nice to have another data type that validates the hostname as a valid TLD.

@petere
Copy link
Owner

petere commented Dec 1, 2015

How would you check for a valid TLD, seeing that they seem to change every couple of weeks?

@fnando
Copy link
Author

fnando commented Dec 1, 2015

Yeah, that sucks. I have some libs that fetch that list and I update it when a new released is published. I can live without those bleeding edge TLDs.

@fnando
Copy link
Author

fnando commented Dec 1, 2015

Here's the TLD list I use: https://data.iana.org/TLD/tlds-alpha-by-domain.txt

@chungy
Copy link

chungy commented Dec 1, 2015

What happens if IANA drops a TLD that you happen to use in your database? What about people that use an alternate root and expect their system to store data with TLDs not part of IANA?

Maybe you just want to make sure someone didn't mistype "COM" as "CMO" -- but going on that path, you can't be sure that an entry with "UA" wasn't just a mistype for "US". It doesn't really seem useful to make this so restrictive, and creates too many faulty assumptions by doing so.

@petere
Copy link
Owner

petere commented Dec 2, 2015

Well, this is not a new category of questions. See also: Which macaddr prefixes are valid? Which time zones are valid? Which IP addresses are valid? And in the realm of email, which addresses can actually be delivered to? And as mentioned in the comment above, what happens to existing data when the definitions change? The answers to these questions should not be hardcoded into the base data type. They can be handled in application-specific ways using facilities such as domains, triggers, user-defined functions, and so on.

@pvh
Copy link

pvh commented Apr 30, 2016

@petere What if the TLDs were listed as a table within the extension's namespace and were enforced via an optional domain constraint?

@petere
Copy link
Owner

petere commented May 6, 2016

I don't think it can work that way. How would you invalidate existing constraints if that table changes? (For that reason, check constraints cannot refer to outside data.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants