> For the complete documentation index, see [llms.txt](https://darwin-framework.gitbook.io/dogs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darwin-framework.gitbook.io/dogs/concepts/validators.md).

# Validators

DOGs validators are based on retained annotation, which are nothing more the annotations which are retained at runtime. All of these annotations are const classes that extend `StructureMetadata` and implement either `FieldValidator` and/or `ClassValidator`.&#x20;

The actual validation however is carried out by the Validatable instance associated with the object which shall be validated. Typically, converters implement the Validatable interface for the type which they can convert.

{% hint style="info" %}
For a list of built in validators refer to [5. Validation](/dogs/guides/5.-validation.md)
{% endhint %}

## Validation Flow (DefaultStructureConverter)

All validators, no matter if it's FieldValidator or a ClassValidator, define the methods getCachedValue, validate and isApplicable. The getCachedValue method is intended to be used for inspecting the structure. After inspection, an immutable dataclass should be created by the getCachedValue which holds all necessary information for validating the field at runtime. The emitted value will then be reused for all following conversion passes.

At this point, neither a DogEngine nor a value are known to the validator and should not be accessed statically, circumventing safety guarantees.

When the validator is used by the Engine, the validate method gets called with the previously generated cached value, the object which must be validated and the calling DogEngine instance.&#x20;


---

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

```
GET https://darwin-framework.gitbook.io/dogs/concepts/validators.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.
