ash-project / ash-project/ash

Compile-time checks for validations like `attribute_equals`, that verify the first arg is actually an attribute on the resource

Open
#1,504 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Elixir
Stars
2.5k
Forks
422
Avg merge
23h 26m
Merged PRs (30d)
46

Description

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

It can be pretty easy to get mixed up between attributes and arguments, and write validations like `argument_does_not_equal(:number, 0)` - when `number` isn't actually an argument to the action, but an attribute on the resource instead.

Same thing for `argument_equals`, `attribute_equals`, `attribute_does_not_equal`, etc.

This seems like something we might be able to check at compile time, and tell users if the validations can't ever pass due to the argument/attribute not existing when you try to validate something about it.

**Describe the solution you'd like**

A compile-time error when these kind of mistakes are made, telling the user that the validation will never pass (kind of like dialyzer does?)

Bonus points if we can tell them "did you mean [attribute not argument or vice versa]?"

Contributor guide

Open the contributing guide

Research direction

No files or tests are identified in the issue. Start by locating the implementations of argument_equals, argument_does_not_equal, attribute_equals, and attribute_does_not_equal, then determine how their first arguments are checked during compilation; done means invalid attribute/argument references produce a compile-time error, with an optional suggestion for the likely alternative.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.