feat: add init/1 callback to Ash.Policy.Check#2655
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Apr 1, 2026
Merged
feat: add init/1 callback to Ash.Policy.Check#2655zachdaniel merged 1 commit intoash-project:mainfrom
init/1 callback to Ash.Policy.Check#2655zachdaniel merged 1 commit intoash-project:mainfrom
Conversation
There was a problem hiding this comment.
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/1as a new callback onAsh.Policy.Checkand calls it during DSL transform. - Provides default
init/1implementations forAsh.Policy.SimpleCheck,Ash.Policy.FilterCheck, and manual checks (use Ash.Policy.Check). - Adds tests covering successful option normalization and compile-time failure when
init/1returns 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
approved these changes
Apr 1, 2026
Contributor
|
🚀 Thank you for your contribution! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Closes #1118