Exception: SafeType::ValidationError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/safe_type/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, desired_type, key = nil) ⇒ ValidationError

Returns a new instance of ValidationError.



23
24
25
26
27
28
29
30
31
# File 'lib/safe_type/errors.rb', line 23

def initialize(value, desired_type, key=nil)
  super("Validation for " + (key.nil? ? '' : "key (#{key}) with ")  +
        "value (#{value.inspect}) of " +
        "type (#{value.class}) to desired type (#{desired_type}) has failed")

  @key = key
  @value = value
  @desired_type = desired_type
end

Instance Attribute Details

#desired_typeObject (readonly)

Returns the value of attribute desired_type.



21
22
23
# File 'lib/safe_type/errors.rb', line 21

def desired_type
  @desired_type
end

#keyObject (readonly)

Returns the value of attribute key.



19
20
21
# File 'lib/safe_type/errors.rb', line 19

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



20
21
22
# File 'lib/safe_type/errors.rb', line 20

def value
  @value
end