AshCredo.Check.Design.MissingIdentity (ash_credo v0.12.1)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

Attributes like email, username, or slug are almost always intended to be unique. Add a corresponding identity:

identities do
  identity :unique_email, [:email]
end

This check uses Ash's runtime introspection (Ash.Resource.Info) to see the fully-resolved attribute and identity lists - including contributions from extensions like AshAuthentication, which adds an :email attribute via a transformer that the AST scanner cannot see. Migrating to compiled introspection turns this check from "scans the source for known attribute names" into "catches concrete missing identities on extension-contributed attributes too".

Requirements

Your project must be compiled before running mix credo. If Ash is not available in the VM running Credo, the check is a no-op and emits a single diagnostic.

Check-Specific Parameters

Use the following parameters to configure this check:

:identity_candidates

Attribute names that should have a uniqueness identity.

This parameter defaults to [:email, :username, :slug, :handle, :phone].

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.