> For the complete documentation index, see [llms.txt](https://docs.aurelia.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aurelia.io/~/revisions/NShYVVc01DvYc5bgBiwq/aurelia-packages/validation/architecture.md).

# Architecture

Familiarize yourself with the Aurelia Validation plugin and how it all pieces together.

## Overview

There are three different interrelated packages for validation. The relation between the packages are depicted in the following diagram.

![Architecture](https://1654214536-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LndnvRP1t7WKpUte87y%2Fuploads%2Fgit-blob-b78a40eff8fea141ecd2d83cfc09f86092fee498%2Farchitecture%20\(1\).svg?alt=media)

* `@aurelia/validation`: Provides the core validation functionality. Hosts the validator, out-of-the-box rule implementations, and the validation message provider.
* `@aurelia/validation-html`: Provides the view-specific functionalities such as validation controller, `validate` binding behavior, and subscribers. It wraps the `@aurelia/validation` package so that you do not need to register both packages.
* `@aurelia/validation-i18n`: Provides localized implementation of the validation message provider and validation controller. Wraps the `@aurelia/validation-html` package.

The rest of the document assumes that validation is view is more common scenario. For that reason, the demos are mostly integrated with view.

## How does it work

* The validationRules (`IValidationRules` instance) allows defining validation rules on a class or object/instance. The defined rules are stored as metadata in a global registry.

  ![Define rules](https://1654214536-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LndnvRP1t7WKpUte87y%2Fuploads%2Fgit-blob-ccc994647120761cf1bd77215ad5e9a1884810b7%2Fseq-define-rules%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(3\).png?alt=media)
* The instance of `PropertyRule` instance hold the collection of rules defined for a property. In simplified terms it can be described by the diagram below.

  ![Rules class diagram](https://1654214536-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LndnvRP1t7WKpUte87y%2Fuploads%2Fgit-blob-6af69d65f12fd1804ad458424531d5ac22570326%2Fclass-rules%20\(1\)%20\(1\)%20\(1\)%20\(1\).png?alt=media)
* The validator (`IValidator` instance) allows you to execute a [validate instruction](https://github.com/aurelia/aurelia/blob/master/docs/user-docs/aurelia-packages/validation/broken-reference/README.md), which instructs which object and property needs to be validated. The validator gets the matching rules from the RulesRegistry (see the diagram above), and executes those.

  ![Rules class diagram](https://1654214536-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LndnvRP1t7WKpUte87y%2Fuploads%2Fgit-blob-2ec423ba7a73a372193a66c840bec9b6955c3b40%2Fseq-validator%20\(1\)%20\(1\)%20\(2\)%20\(1\).png?alt=media)
* The last piece of the puzzle is to getting the rules executed on demand. For this the validation controller (`IValidationController` instance) is used along with the `validate` binding behavior (more on these later). The binding behavior registers the property binding with the validation controller, and on configured event, instructs the controller to validate the binding. The validation controller eventually ends up invoking the `IValidator#validate` with certain instruction which triggers the workflow shown in the last diagram. The following diagram shows a simplified version of this.

  ![Rules class diagram](https://1654214536-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LndnvRP1t7WKpUte87y%2Fuploads%2Fgit-blob-d6353020a37380c1ad6fc2cc9b517b62add6cc8c%2Fseq-validation-controller%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(3\).png?alt=media)

The following sections describe the API in more detail, which will help understanding the concepts further.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aurelia.io/~/revisions/NShYVVc01DvYc5bgBiwq/aurelia-packages/validation/architecture.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
