Exception: Dry::Types::ConstraintError

Inherits:
TypeError
  • Object
show all
Defined in:
lib/dry/types/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, input) ⇒ ConstraintError

Returns a new instance of ConstraintError.

Parameters:

  • result (String, #to_s)
  • input (Object)


43
44
45
46
47
48
49
50
51
52
# File 'lib/dry/types/errors.rb', line 43

def initialize(result, input)
  @result = result
  @input = input

  if result.is_a?(String)
    super(result)
  else
    super(to_s)
  end
end

Instance Attribute Details

#inputObject (readonly)

Returns:

  • (Object)


39
40
41
# File 'lib/dry/types/errors.rb', line 39

def input
  @input
end

#resultString, #to_s (readonly)

Returns:



37
38
39
# File 'lib/dry/types/errors.rb', line 37

def result
  @result
end

Instance Method Details

#to_sString

Returns:

  • (String)


55
56
57
# File 'lib/dry/types/errors.rb', line 55

def to_s
  "#{input.inspect} violates constraints (#{result} failed)"
end