Skip to content

feat: add init/1 callback to Ash.Policy.Check#2655

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
nallwhy:feat/policy-check-init-callback
Apr 1, 2026
Merged

feat: add init/1 callback to Ash.Policy.Check#2655
zachdaniel merged 1 commit intoash-project:mainfrom
nallwhy:feat/policy-check-init-callback

Conversation

@nallwhy
Copy link
Copy Markdown
Contributor

@nallwhy nallwhy commented Apr 1, 2026

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

Closes #1118

Copilot AI review requested due to automatic review settings April 1, 2026 06:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an init/1 callback for Ash.Policy.Check implementations so policy check options can be validated/normalized at compile time when policies are defined.

Changes:

  • Adds init/1 as a new callback on Ash.Policy.Check and calls it during DSL transform.
  • Provides default init/1 implementations for Ash.Policy.SimpleCheck, Ash.Policy.FilterCheck, and manual checks (use Ash.Policy.Check).
  • Adds tests covering successful option normalization and compile-time failure when init/1 returns an error.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/ash/policy/check.ex Adds the init/1 callback and invokes it during policy transform, plus defaults for manual checks.
lib/ash/policy/simple_check.ex Adds a default init/1 and makes it overridable for simple checks.
lib/ash/policy/filter_check.ex Adds a default init/1 and makes it overridable for filter checks.
test/policy/simple_test.exs Adds coverage for init/1 normalization and error propagation during compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zachdaniel zachdaniel merged commit 69327b0 into ash-project:main Apr 1, 2026
48 of 49 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add init(opts) callback to Ash.Policy.Check

3 participants