class Dry::Types::Constrained

def try(input, &block)

Returns:
  • (Object) - if block given and try fails
  • (Logic::Result, Result) -

Other tags:
    Yieldreturn: -

Other tags:
    Yieldparam: failure -

Parameters:
  • block (#call, nil) --
  • input (Object) --
def try(input, &block)
  result = rule.(input)
  if result.success?
    type.try(input, &block)
  else
    failure = failure(input, result)
    block ? yield(failure) : failure
  end
end