Download the PHP package monkeyscloud/monkeyslegion-validation without Composer
On this page you can find all versions of the php package monkeyscloud/monkeyslegion-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download monkeyscloud/monkeyslegion-validation
More information about monkeyscloud/monkeyslegion-validation
Files in monkeyscloud/monkeyslegion-validation
Download monkeyscloud/monkeyslegion-validation
More information about monkeyscloud/monkeyslegion-validation
Files in monkeyscloud/monkeyslegion-validation
Vendor monkeyscloud
Package monkeyslegion-validation
Short Description Attribute-driven validation & DTO binding for the MonkeysLegion PHP 8.4 framework — self-validating constraints, property hooks, PSR-15 middleware.
License MIT
Package monkeyslegion-validation
Short Description Attribute-driven validation & DTO binding for the MonkeysLegion PHP 8.4 framework — self-validating constraints, property hooks, PSR-15 middleware.
License MIT
Please rate this library. Is it a good library?
Informations about the package monkeyslegion-validation
MonkeysLegion Validation
Attribute‑driven DTO binding & validation for the MonkeysLegion PHP 8.4 framework — self-validating constraints, property hooks, PSR-15 middleware.
✨ Features
- Self-validating constraints — each
#[Email],#[NotBlank], etc. validates itself (no monolithic if/else chain) - PHP 8.4 property hooks —
$result->isValid,$result->errors,$result->errorCount - 24 built-in constraints — strings, numbers, dates, collections, networking, cross-field, and more
- Automatic DTO binding — JSON body + query parameters → strongly‑typed DTO
- PSR‑15 middleware — validates, returns
422 Unprocessable Entityon failure - ValidationResult — structured result object with field-level error queries
- ValidationException — throwable with full result for catch-and-inspect
- Zero magic — no doctrine proxies, only native PHP reflection & attributes
- Extensible — implement
ConstraintInterfacein a single class to add constraints
🛠 Requirements
| Minimum | |
|---|---|
| PHP | 8.4 |
| Extensions | ext-json, ext-mbstring |
| PSR | psr/http-message ^2.0, psr/http-server-handler ^1.0, psr/http-server-middleware ^1.0 |
🚀 Installation
⚡ Quick Start
1. Define a DTO with constraints
2. Validate directly
3. Use the helper function
4. PSR-15 middleware integration
When validation fails the client receives:
5. Handler with validated DTO
📦 Built-in Constraints
Strings
| Attribute | Description |
|---|---|
#[NotBlank] |
Value must not be null, empty string, or empty array |
#[Email] |
Valid e-mail address |
#[Length(min, max)] |
String length within bounds (UTF-8) |
#[Pattern(regex)] |
Matches regular expression |
#[Alpha] |
Letters only |
#[Alnum] |
Letters and digits only |
#[Json] |
Valid JSON string |
Numbers
| Attribute | Description |
|---|---|
#[Numeric] |
Value is numeric (is_numeric) |
#[Min(value)] |
Minimum numeric value |
#[Max(value)] |
Maximum numeric value |
#[Range(min, max)] |
Numeric range |
#[Decimal(scale)] |
Decimal with max scale digits |
Collections
| Attribute | Description |
|---|---|
#[Count(min, max)] |
Array/iterable size within bounds |
#[Choice(choices)] |
Value in allowed list |
Dates
| Attribute | Description |
|---|---|
#[Date(format)] |
Valid date (default: Y-m-d) |
#[After(otherField)] |
Date after another field |
#[Before(otherField)] |
Date before another field |
Networking
| Attribute | Description |
|---|---|
#[Url] |
Valid URL |
#[Ip(allowV6)] |
Valid IP address |
#[UuidV4] |
Valid UUID v4 |
Cross-field & Type
| Attribute | Description |
|---|---|
#[SameAs(otherField)] |
Must match another field |
#[Type(type)] |
PHP type check (string, int, float, bool, array, or class) |
#[Unique] |
Marker for uniqueness (consumer provides checker) |
#[Callback(fn)] |
Custom callable validation |
🪄 Creating Custom Constraints
Implement ConstraintInterface — the constraint is the validator:
Now #[Slug] is usable on any DTO property — no registration needed.
🧪 Testing
57 tests, 71 assertions covering all 24 constraints.
🗺 Roadmap
- 🌐 I18n-aware validation messages via
monkeyslegion-i18n - 📚 Constraint composition (
#[Each(new Email())]style) - 🔄 Async validation for remote checks (uniqueness, etc.)
- 🧰 CLI generator for DTO scaffolding
🙌 Contributing
- Fork & create a feature branch.
- Follow MonkeysLegion v2 code standards.
- Add unit tests (
vendor/bin/phpunit). - Open a PR.
📄 License
Released under the MIT License © 2026 MonkeysCloud.
All versions of monkeyslegion-validation with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.4
ext-json Version *
ext-mbstring Version *
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/http-factory Version ^1.1
ext-json Version *
ext-mbstring Version *
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/http-factory Version ^1.1
The package monkeyscloud/monkeyslegion-validation contains the following files
Loading the files please wait ...