Opus.Pipeline.Stage.Check (Opus v0.8.4) View Source

The check stage is intended to assert its input fulfils certain criteria otherwise the pipeline is halted.

Its implementation must return true to proceed running any next steps. When the check fails, an Atom error message is provided by default to allow for pattern-matching.

defmodule CreateUserPipeline do
  use Opus.Pipeline

  check :valid_params?, with: &UserValidator.validate/1
end

When the :valid_params? check fails, the return value of the pipeline will be: {:error, %Opus.PipelineError{error: :failed_check_valid_params?}}