Ash Framework: Diving into Validation | Joseph Koski’s Blog

Ash Framework uses the changeset pattern for validation, where a changeset is a product type holding both valid and invalid states simultaneously, but validation is fundamentally a sum type problem requiring a value to be either valid or invalid. While changesets enable straightforward expression of state machine rules and conditional validation execution (such as skipping expensive checks when prior validations fail), the framework's inability to enforce exclusivity between the valid? flag and accumulated errors means it cannot prevent illegal states like being marked valid while containing errors. Ash validations can be defined at both the resource level (as attribute constraints) and action level (as custom validators), with results converted through changeset threading to accumulate errors, though this sequential threading prevents parallel execution of expensive validations.

Visit Original Article →

⌘K

Start typing to search...

Search across content, newsletters, and subscribers