# Sequence of Validation pipeline

The Validation pipeline will be executed as follows (illustrated in the image below):

1. Initialize Variables Execute Validation>Code tab>On Initialize function. Execute Code tab>Validation steps function.
2. The Validation Step sequences are:&#x20;
   1. Initialize Variables&#x20;
   2. Execute Code>On Initialize&#x20;
   3. Execute Criteria&#x20;
   4. If Criteria is True, Execute Code>On True&#x20;
   5. If Criteria is False, Execute Code>On False
3. Depending on the Exit Validation Action value (True or False)&#x20;
4. Execute Validation>Code tab>On Validation step success or On Validation step fail function
5. Execute Validation>Code tab>On Exit function&#x20;
6. The validation pipeline exits correctly when the Action Set Validation Response is invoked&#x20;
7. Error at any point in execution, Exit Validation with an error message.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_11/ch11validseq.png" alt=""><figcaption></figcaption></figure>

The following image illustrates sequences when a API gateway receives data:

1. The Validation pipeline and Flow details are configured in the API gateway template.&#x20;
2. Data enters the Langstack application to be processed.&#x20;
3. After the Langstack application checks, it enters the dedicated API gateway for the API.&#x20;
4. The data with the associated Validation pipeline and Flow are passed to the API from the API gateway.&#x20;
5. If the API created or updated an entity record with a Validation pipeline or a Flow associated with the API gateway, the entity record is then passed to the Validation pipeline before storing the data into the target entity. The Flow is triggered after the entity record is created or updated.<br>

   The following image represents how a Validation pipeline works with data flow through the API gateway and API.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_11/ch11validinapigtwayflow.png" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://docs.langstack.com/welcome/get-started/learn-langstack/validation-pipeline/sequence-of-validation-pipeline.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
