Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Validation Laravel Package

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.

View on GitHub
Deep Wiki
Context7

PHP Standalone Validation Library

Frequently asked questions about Validation
How do I install rakit/validation with Composer?
Run composer require rakit/validation in your project. The library has zero runtime dependencies, so it installs cleanly into any Composer-based PHP application. After installation, create a Validator instance, call make() with your data and rule array, and inspect passes() or errors().
Does rakit/validation require Laravel?
No. Rakit Validation is a standalone, framework-agnostic library that borrows Laravel's familiar rule syntax such as required|email|max:100 without pulling in illuminate/validation. It suits APIs, form handlers, shared libraries, and legacy services that cannot depend on Laravel. If your application already runs Laravel 8 or newer, the framework validator is usually the better choice unless framework independence is an explicit requirement.
Which PHP versions does rakit/validation support?
The v1.0.0 release raises the minimum PHP version from 5.5 to 7.0, which is the floor stated in the release notes. That does not confirm that PHP 8.x is tested and supported, and PHP 7.0 through 7.3 are end-of-life. Run a time-boxed spike on your actual production runtime covering representative rules, nested inputs, custom closures, and localized messages before committing.
How do I validate nested arrays and wildcard keys with rakit/validation?
Use dot notation in your rule keys, for example items.*.price with rules like required|numeric|min:0. The wildcard expands so each element in the nested array is validated individually. This makes it practical to validate JSON payloads and multi-row form submissions without writing loops.
How do I add a custom validation rule in rakit/validation?
Register a closure or callback rule on the validator and return a boolean result. In v1.0.0 every Rule::check() implementation must return a bool, so avoid returning truthy values. You can pair the custom rule with a custom message keyed by field and rule name to produce a clear error.
How do I customize or translate error messages in rakit/validation?
Pass a messages array when creating the validator, keyed by field.rule or by rule name, to override the defaults. Because error messages are translatable out of the box, you can supply localized strings for each language your application serves. Be aware that some rules such as in, not_in, and uploaded_file generate dynamic messages in v1.0.0.
Does rakit/validation support file upload validation?
Yes, v1.0.0 adds file-upload validation including mimes checks, uploaded_file for multiple files, and file-size handling through min, max, and between. This widens the library's fit to upload-handling services outside Laravel. Test the new rules against your real upload payloads, since the upload-related messages and behavior are dynamic.
What breaking changes are in rakit/validation 1.0.0?
ErrorBag::firstOfAll() now returns an associative array instead of an indexed one, and Rule::check() must return a bool. The default rule now mutates empty values via the ModifyValue trait, which can surprise code that assumed validation never changes input. The uploaded_file rule also has dynamic messages and behavior. Any consumer pinned to 0.x will break silently at the call site on upgrade.
How do I unit test validation rules with rakit/validation?
Instantiate the Validator directly in your test, call make() with fixture data and rules, then assert passes(), fails(), and the contents of errors()->all() or errors()->first(). No framework test helpers are required because the library is standalone. Cover nested and wildcard inputs, custom closure rules, and localized messages in your test matrix.
Is rakit/validation actively maintained and how does it compare to alternatives?
The 1.0.0 release, PHP_Codesniffer adoption, typehints, and PHPDoc improvements indicate active maintenance under the MIT license, though no published support policy or confirmed PHP 8.x testing exists. Compared with Respect\Validation's object-chain API and Symfony Validator's constraint objects, Rakit is closest to Laravel's string rule syntax. Keep it behind an internal validation interface so you can swap to native framework validation, Symfony Validator, or Respect\Validation if needed.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager