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_simple_no_owner.ex
Raw

test/support/test_command_simple_no_owner.ex

defmodule TestCommandSimpleNoOwner do
@moduledoc false
defstruct [
:id,
:name
]
end
defimpl Commanded.Middleware.Uniqueness.UniqueFields, for: TestCommandSimpleNoOwner do
def unique(%TestCommandSimpleNoOwner{}),
do: [
{:name, "has already been taken", Faker.Random.Elixir.random_bytes(16), no_owner: true}
]
end