Skip to content

alias Athena::Validator::Constraints::Callback::CallbackProc #

Convenience alias to make creating AVD::Constraints::Callback procs easier.

# Create a proc to handle the validation
callback = AVD::Constraints::Callback::CallbackProc.new do |value, context, payload|
  return if (value = value.get(Int32)).even?

  context.add_violation "This value should be even."
end

# Instantiate a callback constraint with this proc
constraint = AVD::Constraints::Callback.new callback: callback

Alias definition

Athena::Validator::Constraints::Callback::ValueContainer, Athena::Validator::ExecutionContextInterface, Hash(String, String)? -> Nil