Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Auto-detect whether fields from validation errors are attributes or arguments #2360

@jsw800

Description

@jsw800

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Is your feature request related to a problem? Please describe.

When writing a custom validation, if I return

{:error, field: :my_argument, message: "message"}

from the validate callback, it generates an Ash.Error.Changes.InvalidAttribute error, even if the specified field is an argument.

Describe the solution you'd like

It seems to me like it would make sense to automatically detect whether it's an attribute or argument and return the associated exception type.

Describe alternatives you've considered

This isn't a huge deal because I can call Ash.Error.Changes.InvalidArgument.exception directly and return that from the validate callback, but it's a bit more verbose IMO

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Someday

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions