Exception: Dry::Types::ConstraintError

Inherits:
CoercionError show all
Defined in:
lib/dry/types/errors.rb

Instance Attribute Summary collapse

Attributes inherited from CoercionError

#meta

Instance Method Summary collapse

Methods inherited from CoercionError

handle

Constructor Details

#initialize(result, input) ⇒ ConstraintError

Returns a new instance of ConstraintError.

Parameters:

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


124
125
126
127
128
129
130
131
132
133
# File 'lib/dry/types/errors.rb', line 124

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)


120
121
122
# File 'lib/dry/types/errors.rb', line 120

def input
  @input
end

#resultString, #to_s (readonly)

Returns:



118
119
120
# File 'lib/dry/types/errors.rb', line 118

def result
  @result
end

Instance Method Details

#messageString Also known as: to_s

Returns:

  • (String)


136
137
138
# File 'lib/dry/types/errors.rb', line 136

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