AshPhoenixGenApi.Verifiers.VerifyDomainConfig (ash_phoenix_gen_api v1.0.3)

Copy Markdown View Source

Verifier for the gen_api section of AshPhoenixGenApi.Domain.

This verifier performs compile-time validation of the PhoenixGenApi domain-level configuration. It checks:

  1. Supporter module name — The supporter_module must be a valid Elixir module name (atom).

  2. Service configuration — When define_supporter? is true, the service must be configured.

  3. Resource consistency — All resources in the domain that have the AshPhoenixGenApi.Resource extension must also have a service configured in their gen_api section. If a resource doesn't have its own service, the domain's service will be used as a fallback, so the domain must have one in that case.

  4. Request type uniqueness across resources — No two resources in the domain may expose the same request_type string. This prevents routing conflicts on the gateway node.

  5. Supporter module not already defined — When define_supporter? is true, warns if the supporter module already exists (which could indicate a conflict with a manually-defined module).

  6. Push nodes configuration — When push_nodes is configured, validates that it is either a list of atom node names, an MFA tuple {module, function, args}, :local, or nil. Lists must contain only atoms, and MFA tuples must have the correct structure.

  7. Permission callback configuration — When permission_callback is configured, validates that it is either a valid MFA tuple {module, function, args} or nil. MFA tuples must have the correct structure (module and function must be atoms, args must be a list).

Error Messages

The verifier raises Spark.Error.DslError with descriptive messages and the path to the offending configuration.