Packages

Use CommandedUniquenessMiddleware to ensure short-term value uniqueness, usually during Commanded command dispatch.

Current section

Files

Jump to
commanded_uniqueness_middleware test support test_command_partition1.ex
Raw

test/support/test_command_partition1.ex

defmodule TestCommandPartition1 do
defstruct [
:id,
:name
]
end
defimpl Commanded.Middleware.Uniqueness.UniqueFields, for: TestCommandPartition1 do
def unique(%TestCommandPartition1{id: id}),
do: [
{:name, "has already been taken", id, partition: "SomeCommonPartition"}
]
end