Class: Synapse::Command::ActiveModelValidationFilter

Inherits:
CommandFilter
  • Object
show all
Defined in:
lib/synapse/command/filters/validation.rb

Instance Method Summary collapse

Instance Method Details

#filter(command) ⇒ CommandMessage

Returns The command to dispatch on the bus.

Parameters:

Returns:

Raises:



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/synapse/command/filters/validation.rb', line 7

def filter(command)
  payload = command.payload

  if payload.respond_to? :valid?
    unless payload.valid?
      raise ActiveModelValidationError, payload.errors
    end
  end

  command
end