class InputSanitizer::TypeMismatchError

Public Class Methods

new(value, type) click to toggle source
Calls superclass method
# File lib/input_sanitizer/errors.rb, line 66
def initialize(value, type)
  @value = value
  @type = type

  message = case @type
  when :integer
    "must be an integer"
  when :url
    'must be a valid URI (include the scheme name part, both http and https are accepted, '\
    'and the hierarchical part)'
  else
    "must be a value of type '#{type}'"
  end

  super(message)
end

Public Instance Methods

code() click to toggle source
# File lib/input_sanitizer/errors.rb, line 55
def code
  case @type
  when :integer
    :not_an_integer
  when :url
    :invalid_uri
  else
    :invalid_type
  end
end