class Dry::Types::Constrained

def try(input, &block)

Other tags:
    Api: - public

Returns:
  • (Object) -
  • (Logic::Result) -

Other tags:
    Yieldreturn: -

Other tags:
    Yieldparam: failure -

Parameters:
  • input (Object) --
  • input (Object) --

Overloads:
  • try(input)
  • try(input)
def try(input, &block)
  result = rule.(input)
  if result.success?
    type.try(input, &block)
  else
    failure = failure(input, ConstraintError.new(result, input))
    block_given? ? yield(failure) : failure
  end
end