Respect\Validation
Fluent PHP validation engine with 150+ chainable, composable validators.
Repository Health
Technical Analysis
Respect\Validation is a standalone PHP validation library built around a fluent, chainable interface. Complex rules read almost like a sentence — v::numericVal()->positive()->between(1, 255)->isValid($input) — and can be composed from a catalog of more than 150 fully tested validators covering strings, numbers, dates, collections, network formats, and more.
Beyond simple pass/fail checks, it offers rich, structured exception handling so you can produce detailed, nested error messages suitable for form feedback and APIs, making it a comprehensive validation engine rather than a bag of helpers.
What You Get
- A fluent, chainable API for composing validation rules via the
vbuilder - Over 150 fully tested validators for strings, numbers, dates, collections, and formats
- Three validation modes: boolean
isValid, exception-throwingassert, and single-errorcheck - Structured, nested exception handling for producing detailed error messages
Common Use Cases
- Validating HTTP request and form input in web applications and APIs
- Enforcing domain invariants on value objects and DTOs
- Building reusable, composable rule sets shared across a codebase
Under The Hood
Architecture - The library is organized around a central static factory (v / Validator) that instantiates individual Rule objects, each a small class implementing a common validation contract. Rules compose into a tree, and evaluation walks that tree; failures raise dialect-specific exceptions that mirror the rule structure, so nested rules yield nested, templated messages. Validators live under src/ as one class per rule, with template/message concerns separated from validation logic.
Tech Stack - Modern PHP (the current 3.x line targets PHP 8.5) split into focused Respect packages — respect/config, respect/fluent, respect/parameter, and respect/string-formatter — plus psr/container. Tooling includes PHPUnit, PHPStan, PHP_CodeSniffer, phpbench, and MkDocs-based documentation.
Code Quality - This is a mature, heavily maintained project: 6,000+ stars, 195 contributors, and 2,400+ commits, with CI, Codecov coverage, static analysis (PHPStan), and a coding-standards gate. Every validator is documented and tested, and the README emphasizes the fully-tested nature of the 150+ rules.
API Design - The fluent chaining API is the library’s signature strength: rules read declaratively, the three evaluation modes (isValid/assert/check) cover UI, programmatic, and fail-fast needs, and the consistent naming across 150+ validators keeps discovery easy. Extensive documentation on readthedocs lowers the learning curve despite the breadth of features.