Sha256: 5e30b134fafd8c1314d5cabbf5290542733219276882cbbe30f0d39bc467af90
Contents?: true
Size: 795 Bytes
Versions: 5
Compression:
Stored size: 795 Bytes
Contents
module Janis module Parsing module Validations def self.validate(entry) validate_matchable(entry) validate_format(entry) # Add specific validations like "must not include letters", "must not include special chars other than : or . . ." # "numbers separated by the . must not have more than 3 digits" # etcetera end private def self.validate_matchable(entry) raise "Entry is does not respond to #match." unless entry.respond_to?(:match) end def self.validate_format(entry) format_regex = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}/ raise "Entry has an invalid format." unless entry.matches? FORMAT_REGEX # This one covers unexpected situations end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
janis-0.1.4 | lib/janis/validations.rb |
janis-0.1.3 | lib/janis/validations.rb |
janis-0.1.2 | lib/janis/validations.rb |
janis-0.1.1 | lib/janis/validations.rb |
janis-0.1.0 | lib/janis/validations.rb |