How to use validations without tying them to resource?

I have custom_fields attribute {:array, :map} that contains array of custom fields and their Validation rules. I’d like to validate these fields using AshPhoenix.Form.

How can I validate the following fields without associating them with a resource?

[
  %{field: "name", validations: [required: true, min_length: 3]},
  %{field: "age", validations: [required: true, min: 18]}
]

There isn’t really much built in to Ash that is going to let you do this. You’ll have to roll your own behavior using custom changes, returning errors from changes, etc.

1 Like

I will write a custom validator to handle this. Thanks @zachdaniel.