How to handle submit-only actions without data layer but with validations?
Hi everyone, I'm just getting started with Ash and ran into a challenge when trying to build a LiveView form that validates input and then sends the data to an external API, without using a data_layer.
I'm using a create action with validates and a change/3 callback for the external logic. The issue is: change/3 is called before validations are applied, and changeset.valid? is already true, so my logic executes even when the input is invalid.
Since I'm not using a data_layer, before_action and after_action hooks are not triggered — which would have been ideal for running the API call only after validation.
I already solved the issue of distinguishing between validate and submit (in LiveView) by passing a form_action argument manually.
Now my question is: how can I run logic after validations have been applied, in a non-persistent action?
Here’s a simplified version of what I’m doing:
The issue is that changeset.valid? is already true before validations have actually run.
Thanks, folks — really appreciate it in advance!
I'm using a create action with validates and a change/3 callback for the external logic. The issue is: change/3 is called before validations are applied, and changeset.valid? is already true, so my logic executes even when the input is invalid.
Since I'm not using a data_layer, before_action and after_action hooks are not triggered — which would have been ideal for running the API call only after validation.
I already solved the issue of distinguishing between validate and submit (in LiveView) by passing a form_action argument manually.
Now my question is: how can I run logic after validations have been applied, in a non-persistent action?
Here’s a simplified version of what I’m doing:
In the resource
In the LiveView
In PatientLogic
The issue is that changeset.valid? is already true before validations have actually run.
Thanks, folks — really appreciate it in advance!
