# Complex validations (custom)

Complex validations requiring algorithm implementation are implemented by developers and added to the validator library located in **Eximee Validation**. If the validation is to be performed through external services (e.g. an ESB bus), it is necessary to use **Service Proxy** to make the given service available.

If validations do not require a connection to external services, lightweight script validators can be used (more in: [Script validators (validationScript)](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/walidatory-skryptowe-validationscript)). Complex validators can be used for form fields, pages, or complex components (used later in the form).

### Complex validations for components <a href="#walidacjezlozone-walidacjezlozonedlakomponentow" id="walidacjezlozone-walidacjezlozonedlakomponentow"></a>

In addition to required fields and masks, specialized external validators can also be added to components.

#### **Attaching a validator**

To attach a validator, go into the artifact edit mode and select any component that can have a validator attached. Then click the section **Data quality** in the component properties menu. After expanding the section, we will see the subsection **VALIDATORS**.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2F4MeP4CH1Q60LJ5wqoSRv%2Fimage.png?alt=media&#x26;token=060b9cc0-e3da-411d-b2c5-50b306e6e933" alt=""><figcaption><p><em>Illustration 1. The "Data Quality" section with the VALIDATORS subsection</em></p></figcaption></figure>

After clicking on **VALIDATORS** or the pencil icon, the validators window will slide out.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FAJf0ZQCKd5wMJbUMORhb%2Fimage.png?alt=media&#x26;token=05cc4bbd-f633-4f40-a257-f679486ca5ad" alt=""><figcaption><p align="center"><em><strong>Figure 2.</strong> Validators window</em></p></figcaption></figure>

After selecting the option **Select validator** we will be able to search for and select the given validator. The list contains standard validators and script validators. For a validator, you can define an invocation condition (field **Add condition**). This is a JavaScript condition in which you can use form fields or session variables available in the form. The way to create conditions is described in [Condition definition expression language (conditions with getValue)](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/jezyk-wyrazen-definiowania-warunkow-warunki-z-getvalue).

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FMt2dU5eHcbatbpLg0gVO%2Fimage.png?alt=media&#x26;token=3eef22d1-7b90-410c-933b-51cd5f46a4e2" alt=""><figcaption><p align="center"><em><strong>Figure 3.</strong> Adding a validator</em></p></figcaption></figure>

#### **Simulation**

Validators, just like external services, support the ability to replace their behavior with a simulation script. Attaching such a script requires selecting the tab in the validators window **Simulation** and selecting the available simulation script from the list.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FjXNOLjYwgFvYvoHn21dS%2Fimage.png?alt=media&#x26;token=2f2421e6-bb34-46f8-8829-690d02e895b3" alt=""><figcaption><p align="center"><em><strong>Figure 4.</strong> Tab for attaching a simulation script</em></p></figcaption></figure>

From here, we can also choose to create a new script by clicking the button **Generate new script**. The newly created script will automatically have content generated in accordance with the validator and the described separated code sections.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FPMolqKwvibDyEdSBXeVg%2Fimage.png?alt=media&#x26;token=c99d1913-5b6c-4ef6-8ae4-b2818c5c93f0" alt=""><figcaption><p align="center"><em><strong>Figure 5.</strong> Creating a simulation script</em></p></figcaption></figure>

It should be remembered that such scripts will be executed **only** when opening the form with **enabled** form logic simulation mode!

### Complex validations on the page <a href="#walidacjezlozone-walidacjezlozonenastronie" id="walidacjezlozone-walidacjezlozonenastronie"></a>

#### **Adding validators on the page**

Validators can also be added on the page:

* If the page listens for the fields that we pass to the validator, the validator is called when the field that the page listens to changes.
* If the page will not listen to fields, the validator will be called only after clicking the button **Next/Send.**\ <br>

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FSYWXG5hO5TQ76zuSKSVz%2Fimage.png?alt=media&#x26;token=d3fb8a8c-072e-4231-b4d1-1fc9140cd92b" alt=""><figcaption><p align="center"><em><strong>Figure 6.</strong> Properties panel with two validators added for the Page1 page</em></p></figcaption></figure>

#### **Adding** **validators on a complex component**

It is possible to add validators to a complex component. They will work as if they were added on the page where the complex component is located.

### Adding translations for validation messages <a href="#walidacjezlozone-dodanietlumaczenkomunikatowwalidacji" id="walidacjezlozone-dodanietlumaczenkomunikatowwalidacji"></a>

Each validator returns a validation message. The message content may already be translated into Polish or may be in another language. After attaching the validator, go to the tab **Translations** and find the correct error key in order to change the translation.

If the validator message contains parameters, then the translation should also include them in the appropriate place.

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FLmk7usP2YfqKynsFaF3k%2Fimage.png?alt=media&#x26;token=922b77bc-3ec6-4818-9cc3-bfb1f2d70e31" alt=""><figcaption><p align="center"><em><strong>Figure 7.</strong> Example of message translation for a validator with parameter passing</em></p></figcaption></figure>

{% hint style="info" %}
More information in [Creating validators](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/logika-biznesowa/scriptcode/walidatory-skryptowe-validationscript/tworzenie-i-podpiecie-walidatorow-skryptowych).
{% endhint %}


---

# 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.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/praca-z-komponentami-bazowymi/walidacja-wartosci-komponentow/walidacje-zlozone-wlasne.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.
