Links

Implement custom validation

It might happen that you need to implement the advanced validation of the table or form fields based on a certain condition or data source request while editing or creating new records.
In the use case, we will set up validation of a date&time field while editing a table record. If the validation fails, the edit action will not be executed and a user will see an error.
  1. 1.
    Create a multi-step action. Add a Condition action as a first step. Specify the validation code, e.g.: return new Date({{ui.table.editedRow.data.end_date}}) >= new Date({{ui.table.editedRow.data.start_date}});
2. For the True condition, add the edit action. For the False condition, add a Code action and specify the code with your custom error message, e.g.: throw new Error("Start date can't be greater than end date.");
3. Next, proceed to the Config section of the action - Toasts. Tick the error message and refer to the action as {{actions.yourAction.error.message}}