vlucas/valitron
Valitron is a lightweight, dependency-free PHP validation library with simple, readable rules. Validate arrays like $_POST in one call, get structured errors, and extend with custom rules and callbacks—minimal code, well tested, and framework-agnostic.
requiredWith, requiredWithout) is a priority.$_POST, JSON) with granular error responses.FormRequest validation for reusable, framework-agnostic rules.Adopt Valitron when:
Validator::extend() or Rule objects.settings.*.threshold).Look elsewhere when:
Rule::unique()).For Executives: "Valitron is a lightweight, dependency-free validation library that lets us own our data rules without bloating our codebase. It’s ideal for APIs, microservices, or legacy systems where we want to avoid Laravel’s full stack. By adopting this, we reduce technical debt, improve performance (no Symfony dependencies), and maintain flexibility for future tooling. For example, it’s perfect for validating user inputs in our new CLI tool—no framework overhead, just pure validation logic."
For Engineers: *"Valitron gives us a simple, chainable API for validation with no dependencies, making it easier to:
requiredWith or requiredWithout without custom logic.Comparison to Laravel’s validator:
| Feature | Valitron | Laravel Validator |
|---|---|---|
| Dependencies | None (pure PHP) | Symfony components (~500KB+) |
| Syntax | Fluent, chainable | Method chaining (e.g., Rule::...) |
| Conditional Rules | Built-in (requiredWith, etc.) |
Requires custom rules |
| Nested Arrays | Dot notation (user.*.email) |
Limited support |
| Use Case | Lightweight, standalone PHP | Laravel-centric projects |
Proposal: Use Valitron for new validation-heavy components (e.g., API endpoints, forms) where minimalism is key. For Laravel projects, stick with the built-in validator to leverage ecosystem tools like translation or database-backed rules."*
How can I help you explore Laravel packages today?