On Oct 4, 2012, at 5:02 PM, Frank Rietta <[address removed]> wrote:
Is this the best way to do this though? What have others done for validating domain names?
I definitely wouldn't work hard at it though. Matching formal RFC specs doesn't tell you anything about whether the value will work. True 'validation' will only happen when you try doing whatever you need to do with that domain name. If you're supposed to access it and you succeed at getting data back, the name is valid. If you're supposed to register it and you get an error that the name already exists, the name is invalid.
Because Rails makes simple validations so easy, a lot of Rails apps get bogged down in excessively validating things that don't have a cost. In most cases it just doesn't matter if Madonna left the "last name" field blank, or if someone put spaces in their phone number. Business can usually still get done. You only need to validate things that would cause the fundamental business requirement to fail. The test for whether a domain name will 'work' depends on what the requirement is, but it almost certainly isn't counting characters.