feat: add batch_validate callback to Ash.Resource.Validation#2650
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Mar 29, 2026
Merged
feat: add batch_validate callback to Ash.Resource.Validation#2650zachdaniel merged 1 commit intoash-project:mainfrom
zachdaniel merged 1 commit intoash-project:mainfrom
Conversation
Contributor
|
Nice! One big thing before I dive in to review: there should be no need for validations to run after the action 😄. We should really only need |
7117a31 to
f7f49ba
Compare
Contributor
Author
|
Okay it should be updated! |
zachdaniel
reviewed
Mar 27, 2026
| @doc """ | ||
| Runs on each batch before it is dispatched to the data layer. | ||
| """ | ||
| @callback before_batch( |
Contributor
There was a problem hiding this comment.
Should remove these callbacks now.
zachdaniel
reviewed
Mar 27, 2026
| |> Enum.reduce(batch, fn | ||
| {%{validation: _}, _index}, batch -> | ||
| batch | ||
| {%{validation: {module, validation_opts}}, _index}, batch -> |
Contributor
There was a problem hiding this comment.
This logic is getting more complex now and is repeated. Lets move it out into BatchHelpers?
zachdaniel
requested changes
Mar 27, 2026
Contributor
zachdaniel
left a comment
There was a problem hiding this comment.
Looks good, almost there! Also a merge conflict to investigate.
Validations now support batch processing during bulk operations via batch_validate/3, before_batch/3, and after_batch/3, mirroring the existing pattern on Ash.Resource.Change. This allows validations to process entire batches at once instead of per-changeset, enabling optimizations like batched external API calls or cross-record checks. Made-with: Cursor
f7f49ba to
3d5441c
Compare
zachdaniel
pushed a commit
that referenced
this pull request
Mar 29, 2026
Validations now support batch processing during bulk operations via batch_validate/3, mirroring the existing pattern on Ash.Resource.Change. This allows validations to process entire batches at once instead of per-changeset, enabling optimizations like batched external API calls or cross-record checks.
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.
Summary
Closes #1405
Contributor checklist
Leave anything that you believe does not apply unchecked.