Sha256: 3b1245fd606a69baa18c772c78e2aa4bcc72c1ac64e9ce26fd1e31209e2b58b9
Contents?: true
Size: 638 Bytes
Versions: 2
Compression:
Stored size: 638 Bytes
Contents
module Validator class Domain LENGTH = 255 LABEL_LENGTH = 63 def initialize(value) @value = value end def valid_by_length?(length = nil) @value.length <= (length || LENGTH) end def valid_by_label_length?(label_length = nil) !(@value.split(".").find{|f| f.length > (label_length || LABEL_LENGTH) and f.length > 1 }) end def valid_by_regexp? @value =~ /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/i end # valid if passes all conditions def valid? valid_by_length? and valid_by_label_length? and valid_by_regexp? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validator-0.1.0 | lib/validator/domain.rb |
validator-0.0.2 | lib/validator/domain.rb |