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

# Overview

The Validation package gives Quantum a small rule engine for checking request data, uploads, and model-backed existence rules before you continue into controller or service logic.

Use it when you want to validate an input array against one or more named rules and then return translated field errors back to the caller.

## Main entry points

The package is centered around two classes:

* `Quantum\Validation\Validator` stores rules, runs validation, and collects errors
* `Quantum\Validation\Rule` is a fluent rule builder for `setRule()` and `setRules()`

## Typical flow

```php
use Quantum\Validation\Rule;
use Quantum\Validation\Validator;

$validator = new Validator();

$validator->setRules([
    'email' => [
        Rule::required(),
        Rule::email(),
    ],
    'password' => [
        Rule::required(),
        Rule::minLen(6),
    ],
]);

if (!$validator->isValid($request->all())) {
    return ['errors' => $validator->getErrors()];
}
```

## When to use it

This package fits well when:

* you already have request data as an array
* validation should stay close to a controller or middleware boundary
* you want one place to combine built-in and custom rules
* you want user-facing error messages to come from the Lang package

## What the package covers

The built-in rules are grouped around a few common jobs:

* presence and format checks like `required`, `email`, `date`, and `regex`
* type and numeric checks like `integer`, `float`, `boolean`, `minNumeric`, and `maxNumeric`
* string length and membership checks like `minLen`, `containsList`, and `doesntContainsList`
* file upload checks like `fileSize`, `fileMimeType`, `fileExtension`, and `imageDimensions`
* environment or integration checks like `urlExists`, `exists`, `unique`, and `captcha`

See [Rules](/docs/packages/validation/rules.md) for the full rule set and the important caveats for each category.

## Important constraints

* Validation is instance-local. A `Validator` keeps its rules until you delete or flush them.
* Missing fields are normalized to an empty string before validation runs.
* Rules do not short-circuit. If one field has three failing rules, all three errors are collected.
* Some rules depend on other packages at runtime, especially `exists`, `unique`, `captcha`, and translated error output.
* File rules expect `Quantum\Storage\UploadedFile` values. A missing upload is not skipped automatically.


---

# 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, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/validation/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
