Exception: InputSanitizer::ValueError

Inherits:
ValidationError show all
Defined in:
lib/input_sanitizer/errors.rb

Instance Attribute Summary

Attributes inherited from ValidationError

#field, #value

Instance Method Summary collapse

Constructor Details

#initialize(value, min, max) ⇒ ValueError

Returns a new instance of ValueError.



116
117
118
119
120
121
122
123
124
# File 'lib/input_sanitizer/errors.rb', line 116

def initialize(value, min, max)
  if min && max
    super("must be between #{min} and #{max}, given: #{value}")
  elsif min
    super("must be higher than or equal to #{min}, given: #{value}")
  else
    super("must be lower than or equal to #{max}, given: #{value}")
  end
end

Instance Method Details

#codeObject



112
113
114
# File 'lib/input_sanitizer/errors.rb', line 112

def code
  :invalid_value
end