rakit/validation
Rakit Validation is a standalone PHP validation library inspired by Laravel. It provides familiar validation rules, custom rules, nested array support, and customizable error messages without requiring the Laravel framework.
Validator::make() rules and the same error vocabulary. That's a shared contract, not just a library choice.if (!isset(...)) checks.mimes rule reading from $_FILES, extends uploaded_file to multiple files, and makes min/max/between validate uploaded file size. That turns a previously hand-rolled area — avatar/document/CSV upload validation — into declarative rules. Relevant for admin tooling, import pipelines, and any product surface accepting user-supplied files.TranslationsTrait and Rule::setParameterText / getParametersTexts let us swap translations wholesale and render human-readable field and parameter names in messages ("The Billing email field must be one of Card, Invoice") instead of leaking rule internals. Dynamic in/not_in/uploaded_file messages do this out of the box. This is customer-facing quality, not just plumbing, and it de-risks international expansion on small teams.Adopt when:
illuminate/* into someone else's dependency tree.^1.0 and vendoring if maintenance lapses again.Look elsewhere when:
Rule::check() must now return bool, and ErrorBag::firstOfAll() returns an associative array instead of an indexed one. Anyone on 0.x must plan a migration, not a patch bump.$_FILES-coupled, so they don't help streamed/PSR-7 uploads.What it is: A small, MIT-licensed PHP library that gives any PHP codebase the same Validator::make() API Laravel developers already use — without adopting Laravel. v1.0.0 shipped this cycle: the first release since 2018.
Why it matters: Input validation is where a large share of data-integrity bugs and injection-adjacent defects originate. Standardizing on one expressive, widely understood rule syntax replaces ad-hoc, inconsistent checks with reviewed, testable rules — and lets one team's validation knowledge transfer to every codebase we own. This release also closes a real capability gap: native file-upload validation (MIME type, multi-file, file size) and customer-facing message quality (named parameters, swappable translations), which were previously hand-rolled per project.
Cost: Low. One Composer dependency, no framework lock-in, no infrastructure change, no licensing cost. It can be vendored into our repo if needed.
Risk: Materially reduced, not eliminated. The headline concern in the prior assessment — an eight-year release gap — is retired: there is now an active maintainer shipping a considered 1.0 with code-style enforcement, typehints, and PHPDoc. What remains is no formal support commitment (no LTS, no CVE SLA, no security policy), and this is a breaking release: PHP 7.0 floor, Rule::check() must return bool, and ErrorBag::firstOfAll() changed shape — the last one is product-visible if we render error payloads straight from that method. Mitigations: (a) replace the compatibility spike with a migration spike covering the three breaking changes plus a PHP 8.x check, (b) pin to ^1.0 and hold the vendor/fork decision as a documented contingency, (c) keep the Symfony Validator fallback documented for regulated surfaces.
Recommendation: Adopt for non-critical, framework-less surfaces — internal tools, distributed SDKs, legacy modules, upload-handling features — after the migration spike. Do not adopt for systems with dependency-support obligations. Treat the package primarily as a pattern for standardizing validation semantics, with the library as its cheapest implementation today — and now, a visibly maintained one.
Decision requested: Approve the migration spike (breaking-change inventory + PHP 8.x verification), and record our posture — buy with ^1.0 pinning, fork only if maintenance lapses again — so engineering isn't blocked mid-sprint.
How can I help you explore Laravel packages today?