Download the PHP package fatjon-lleshi/antares-validation without Composer
On this page you can find all versions of the php package fatjon-lleshi/antares-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fatjon-lleshi/antares-validation
More information about fatjon-lleshi/antares-validation
Files in fatjon-lleshi/antares-validation
Package antares-validation
Short Description Lightweight DTO hydration and validation for PHP 8.2+
License MIT
Homepage https://github.com/johnlesis/antares-validation
Informations about the package antares-validation
antares-validation
Lightweight DTO hydration and validation for PHP 8.2+.
Part of the Antares framework — but usable standalone in any PHP project.
Requirements
- PHP 8.2+
- PSR-7 HTTP Message
Installation
Overview
This package provides two things:
- Hydrator — takes raw input data and maps it into a typed readonly DTO
- Validator — validates DTO properties using PHP attributes
They work together: the Hydrator hydrates the DTO, the Validator validates it. You can also use the Validator independently on any class.
Defining a DTO
Mark your DTO class with #[Dto] and declare properties as readonly constructor parameters:
Hydration
The Hydrator takes raw array data and produces a hydrated DTO instance:
If hydration fails (missing required field, wrong type), a HydrationException is thrown.
Strict Mode
Apply #[Strict] to the DTO class to reject unknown input fields. Without it, extra fields are silently ignored:
Passing ['name' => 'John', 'age' => 25, 'role' => 'admin'] will throw a HydrationException because role is not a known field.
bash
composer require fatjon-lleshi/antares-validation
## License
MIT — [Fatjon Lleshi](https://github.com/johnlesis)