lib/terminal_helpers/validations.rb
def validate(value, format, raise_error=false)
      unless FORMATS.key?(format)
        raise FormatError, "Invalid data format: #{format}"
      end
      result = value =~ FORMATS[format] ? true : false
      if raise_error && !result
        raise ValidationError, "Invalid value \"#{value}\" for #{format}"
      end
      result
    end
def validate(value, format, raise_error=false)
      unless FORMATS.key?(format)
        raise FormatError, "Invalid data format: #{format}"
      end
      result = value =~ FORMATS[format] ? true : false
      if raise_error && !result
        raise ValidationError, "Invalid value \"#{value}\" for #{format}"
      end
      result
    end
def validate ( value , format , raise_error = false ) unless FORMATS . key? ( format ) raise FormatError , "Invalid data format: #{format}" end result = value =~ FORMATS [ format ] ? true : false if raise_error && ! result raise ValidationError , "Invalid value \"#{value}\" for #{format}" end result end
Validate data against provided format
Validate data against provided format