Exception: InputSanitizer::TypeMismatchError
- Inherits:
-
ValidationError
- Object
- StandardError
- ValidationError
- InputSanitizer::TypeMismatchError
- Defined in:
- lib/input_sanitizer/errors.rb
Instance Attribute Summary
Attributes inherited from ValidationError
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(value, type) ⇒ TypeMismatchError
constructor
A new instance of TypeMismatchError.
Constructor Details
#initialize(value, type) ⇒ TypeMismatchError
Returns a new instance of TypeMismatchError.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/input_sanitizer/errors.rb', line 66 def initialize(value, type) @value = value @type = type = 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() end |
Instance Method Details
#code ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# 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 |