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