This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'not_naughty' | |
# Load the validations you want to use. | |
NotNaughty::Validation.load 'length', 'presence' | |
Person = Struct.new(:name) do | |
extend NotNaughty | |
validates(:name) { presence and length :minimum => 4 } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to save bytes... | |
var T = true; | |
/* TLDs as of Jan 2013 | |
* For faster lookup we store TLDs as properties of an object. | |
* | |
* Source: http://data.iana.org/TLD/tlds-alpha-by-domain.txt | |
*/ | |
var topLevelDomains = { | |
'ac':T,'ad':T,'ae':T,'aero':T,'af':T,'ag':T,'ai':T,'al':T,'am':T,'an':T,'ao':T,'aq':T,'ar':T,'arpa':T,'as':T,'asia':T,'at':T,'au':T,'aw':T,'ax':T,'az':T, |