zorbash / opus

A framework for pluggable business logic components
MIT License
360 stars 21 forks source link

Accept a function in :error_message #20

Closed zorbash closed 3 years ago

zorbash commented 4 years ago

Current behavior

defmodule ArithmeticPipeline do
  use Opus.Pipeline

  step  :add_one,         with: &(&1 + 1)
  check :even?,           with: &(rem(&1, 2) == 0), error_message: :expected_an_even
  step :do_something_else

The error message should accept a function which will be called with the return value of the previous stage so that the error message can be parameterised.