Commands form the API of your domain. Like Events they are simple data objects.
Commands have descriptive names describing the intent of what you are trying to achieve, for example
Commands inherit from
you can add Validations to commands to ensure correctness. Sequent uses
to enable validations.
class CreateUser < Sequent::Command attrs firstname: String, lastname: String validates_presence_of :firstname, :lastname end
Commands, like Events, are also stored in the EventStore.
In building a web application you typically bind your html form to a Command. You then have to pass
it into the CommandService. The CommandService will only execute valid Commands.
When a Command is not valid a
Sequent::Core::CommandNotValid will be raised containing the validation
When a Command is valid the CommandHandlers registered and interested in this Command
will be invoked.