Valitron
Simple, elegant, dependency-free validation for PHP.
Repository Health
Technical Analysis
Valitron is a standalone PHP validation library with no external dependencies and a focus on readable, concise syntax. You define an array of rules against your data and get back a clear pass/fail result with structured error messages.
It ships dozens of built-in rules — required fields, lengths, formats, dates, comparisons, and more — plus support for custom rules, conditional validation, field labels, and translated error messages, making it a pragmatic choice for validating request payloads and form input.
What You Get
- A dependency-free validator with a chainable, readable API
- Dozens of built-in rules for formats, lengths, dates, and comparisons
- Custom rule registration and conditional/optional validation
- Field labeling and translated error messages in many languages
Common Use Cases
- Validating HTTP request or form input in a PHP application
- Enforcing business rules on data before persistence
- Producing localized, user-facing validation error messages
Under The Hood
Architecture - Nearly all logic lives in a single Validator class that holds the data, an accumulated rule set, labels, and a language/translation map. Rules are stored as callables (built-in methods prefixed validate* or user-registered closures) and executed in validate(), collecting failures into a per-field error array formatted through message templates. Tech Stack - Plain PHP with zero runtime dependencies; language files provide translated messages, and the test suite runs under PHPUnit via GitHub Actions. Code Quality - Well-tested with a long-standing CI pipeline and broad rule coverage; the monolithic validator is large but consistently structured. API Design - Deliberately terse and readable — $v = new Validator($data); $v->rule('required', 'name'); $v->validate(); — with array-based rule declaration and fluent chaining for more complex cases.