module Janis::Parsing::Validations
Public Class Methods
validate(entry)
click to toggle source
# File lib/janis/validations.rb, line 7 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 Class Methods
validate_format(entry)
click to toggle source
# File lib/janis/validations.rb, line 21 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
validate_matchable(entry)
click to toggle source
# File lib/janis/validations.rb, line 17 def self.validate_matchable(entry) raise "Entry is does not respond to #match." unless entry.respond_to?(:match) end