# Validation

{% hint style="success" %}
This is the official documentation of the `forestadmin-agent-django` and `forestadmin-agent-flask` Python agents.
{% endhint %}

![A field failing validation](https://2921382565-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HgnlEINLUAEQC1KgN48%2Fuploads%2Fgit-blob-8668bc8ffc7b3c737c80351447aa58c6eed2f303%2Ffield-validation-error.png?alt=media)

* Columns of type `VARCHAR(15)` will automatically carry a `less than 15 chars` validator.
* Non-nullable columns will automatically carry a `Present` validator.

However, you may want to enforce stricter restrictions than the ones which are implemented in your data source.

### Adding validation rules

The list of operators (`Present`, `LongerThan`, ...) which can be used when adding validators is the same as the [filter operators](https://docs.forestadmin.com/developer-guide-agents-python/data-sources/getting-started/queries/filters#operators).

```python
collection.add_field_validation(
    "firstName", "present"
).add_field_validation(
    "firstName", "longer_than", 2
).add_field_validation(
    "firstName", "shorter_than", 30
).add_field_validation(
    "firstName", "match", r"^[a-z]+$"
)
```


---

# 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.forestadmin.com/developer-guide-agents-python/agent-customization/fields/validation.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.
