Is there anyway to return a changeset from validation module?
I have a not-simple validation using pure Ecto in Phoenix project. And I want to port over to the project that is using Ash.
With Ecto. we used to add errors to changeset in each function
In each function, if the validation passes, we simply pass the changeset through. Otherwise, we add an error to the changeset. This way, the end user can see all errors at once when the changeset is returned.
But in custom validations in Ash, I found that we need to return either
Is there any way to support this pattern? Or are we expected to stop validation after the first failure?
With Ecto. we used to add errors to changeset in each function
def validate_something(changeset, some) do
changeset
|> validate_something_1(some)
|> validate_something_2(some)
|> validate_something_3(some)
endIn each function, if the validation passes, we simply pass the changeset through. Otherwise, we add an error to the changeset. This way, the end user can see all errors at once when the changeset is returned.
But in custom validations in Ash, I found that we need to return either
:ok or {:error, field: field, message: message}, and we can't return the changeset itself.Is there any way to support this pattern? Or are we expected to stop validation after the first failure?
