> For the complete documentation index, see [llms.txt](https://docs.cloudio.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudio.io/creating-datasources/working-with-datasources/creating-a-data-source/defining-server-side-validations/validation-sequence.md).

# Validation sequence

The following sequence is followed for the execution of different types of validations when a DML operation is performed:

1. Call the method handleBeforeProcessRows() on the custom handler once for all the collection of rows that are being posted. The collection of rows includes rows with operations insert, update, delete and validate.
2. Check if the isSkipDML() method returns the value true on the custom handler. If so, then skip all the steps given below.
3. Check if the user has access to perform the insert operation on the DataSource. If not, an exception is thrown to the user and all the steps given below are skipped.
4. If you are performing an update operation, fetch the row from the database matching the primary key values and throw an exception when either zero or more than one rows match the primary key values.
5. Execute the before insert/update/delete/validate validation script in the order of given sequence.
6. Invoke the handleBeforeInsertRow(), handleBeforeUpdateRow(), handleBeforeDeleteRow() or handleBeforeValidateRow() method call on custom handler depending on the type of operation performed on a given row.
7. Set default values based on the attribute definition.
8. Post the data to the database.
9. Insert the activity stream.
10. Execute the after insert/update/delete/validate validation script in the order of given sequence.
11. Call the handleAfterInsertRow() method on the custom handler.
12. Call the handleAfterProcessRows() method on custom handler once for all the collection of rows that are being posted.

{% hint style="info" %}
**Note:** The steps 3 to 6 are performed in a group for each row in a loop. Similarly, steps 10-11 are performed in a group for each row in the collection.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cloudio.io/creating-datasources/working-with-datasources/creating-a-data-source/defining-server-side-validations/validation-sequence.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
