Advertisement
Guest User

Kata 5 q

a guest
Jan 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. In this kata you have to create a domain name validator mostly compliant with RFC 1035, RFC 1123, and RFC 2181
  2.  
  3. For purposes of this kata, following rules apply:
  4.  
  5. Domain name may contain subdomains (levels), hierarchically separated by . (period) character
  6. Domain name must not contain more than 127 levels, including top level (TLD)
  7. Domain name must not be longer than 253 characters (RFC specifies 255, but 2 characters are reserved for trailing dot and null character for root level)
  8. Level names must be composed out of lowercase and uppercase ASCII letters, digits and - (minus sign) character
  9. Level names must not start or end with - (minus sign) character
  10. Level names must not be longer than 63 characters
  11. Top level (TLD) must not be fully numerical
  12. Additionally, in this kata
  13.  
  14. Domain name must contain at least one subdomain (level) apart from TLD
  15. Top level validation must be naive - ie. TLDs nonexistent in IANA register are still considered valid as long as they adhere to the rules given above.
  16. The validation function accepts string with the full domain name and returns boolean value indicating whether the domain name is valid or not.
  17.  
  18. Examples:
  19.  
  20. validate('codewars') == False
  21. validate('g.co') == True
  22. validate('codewars.com') == True
  23. validate('CODEWARS.COM') == True
  24. validate('sub.codewars.com') == True
  25. validate('codewars.com-') == False
  26. validate('.codewars.com') == False
  27. validate('example@codewars.com') == False
  28. validate('127.0.0.1') == False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement