Add required!/1, ash_required/1, and ash_required!/2 (issue #261)#707
Open
dallingson wants to merge 1 commit intoash-project:mainfrom
Open
Add required!/1, ash_required/1, and ash_required!/2 (issue #261)#707dallingson wants to merge 1 commit intoash-project:mainfrom
dallingson wants to merge 1 commit intoash-project:mainfrom
Conversation
…ct#261) - required!/1 and ash_required/1: custom expressions for presence in queries (replacing not is_nil(...)) - PostgreSQL ash_required/1 in ash_functions.ex for filters/calculations - Data layer can?(:required_error) and ash_required!/2 (RequiredError): when value is nil, return Ash.Error.Changes.Required; required_error/2 for the error message - Docs and tests for the new expressions and required_error
Contributor
|
I don't see any particular value in |
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.
Pull request: Add required!/1, ash_required/1, ash_required!/2, and required_error/2
Closes #261
What
Adds custom expressions
required!/1andash_required/1for presence in queries, andash_required!/2plusrequired_error/2for required-field validation that returnsAsh.Error.Changes.Requiredwhen a value is nil.Why
There was no built-in way to express "required/present" in filters and calculations without
not is_nil(...), or to get Ash's standard required error from the data layer when a value is nil.How to use
Presence in queries (filters/calculations):
Required-field validation (returns
Ash.Error.Changes.Requiredwhen nil):When the value is nil, Ash uses
required_error/2and the data layer returns the standard required error.Changes
required!/1andash_required/1for presence in queries.required_error/2and data-layer integration so validation returnsAsh.Error.Changes.Requiredwhen nil.ash_required!/2expression that uses the required-error path when the value is nil.can?(:required_error)and registration of the new functions/expressions.ash_required/1in migrations so it's available in SQL.documentation/topics/advanced/expressions.md.required_error_test.exscoverage.Contributor checklist
Leave anything that you believe does not apply unchecked.