- How do I install saritasa/laravel-fluent-validation?
- Install it with Composer using composer require saritasa/laravel-fluent-validation. The package is MIT licensed, so forking and vendoring are permitted. Because the repository is archived, pin the dependency to a specific commit rather than a floating version constraint.
- Does saritasa/laravel-fluent-validation support Laravel 11 and Laravel 12?
- There is no stated support matrix, and the last release was 2024-01-08, which predates Laravel 11 GA and Laravel 12. Compatibility with illuminate/validation v11 and v12 plus PHP 8.3 and 8.4 is unverified. Run the package's test suite and your own conversion tests against your exact Laravel and PHP matrix before adopting it.
- How do I build sometimes, required_if, and bail rules with a fluent validation builder?
- The package's core idea is that conditional rules such as sometimes, required_if, exclude_if, and bail are expressed as chainable builder calls that compile down to the same array Laravel already accepts. The exact method names and ordering behavior are not documented in the evaluation material, so read the builder-to-array compilation source. Pay particular attention to bail ordering and nullable handling, because a builder that drops or reorders these rules can silently under-validate.
- Does it support nested wildcard keys like items.*.sku and Rule:: objects?
- Nested wildcard keys like items.*.sku and Rule:: objects are not explicitly confirmed in the provided material; the builder is described as emitting the same underlying array, which suggests they can pass through if the builder preserves them. Audit the compilation path for wildcard and object handling. Add explicit equivalence tests for both before relying on them.
- Does the fluent builder return an array or typed rule objects?
- It emits the same underlying array that native Laravel validation uses, so the result can be returned from a FormRequest rules() method or passed to Validator::make(). The trade-off is that array output loses type information, so PHPStan and Larastan will not catch malformed rule structures for you. Keep conversion tests rather than relying on static analysis for correctness.
- How are custom validation messages and attribute names handled?
- Custom messages and attribute-name translation are generally handled by Laravel's messages() and attributes() methods on the FormRequest, not by the rule builder itself. The evaluation material does not detail any package-specific message API. Confirm in the source whether the builder exposes helpers for messages and attribute names before designing around it.
- Is saritasa/laravel-fluent-validation maintained and safe for production?
- The repository is archived, the last release was January 2024, it has a bus factor of one, and there are only 8 stars and 0 dependents. Runtime risk is low because it is a developer-ergonomics layer that constructs rules rather than sitting on the request hot path. The real hazard is silent rule omission, so fork it into a private repository, pin it to a commit, and gate adoption on array-equivalence tests.
- How should I test that fluent rules match native Laravel rules?
- For every migrated FormRequest, assert that the fluent builder output is identical to the legacy hand-written array. Include edge cases for nullable, sometimes, required_if, bail ordering, wildcard keys, and implicit rules such as accepted and declined. Treat any mismatch as a blocker, because a validation library that quietly under-validates is a data-integrity and security problem.
- When should I use fluent validation rules instead of native Laravel arrays?
- Use it when you have heavy FormRequest usage, such as API resources with 20 or more fields, or rule sets duplicated across store and update variants. Native array and string syntax is already readable for small CRUD apps, so the fluent DSL becomes net overhead there. Pilot it on one or two high-density FormRequests, and avoid authentication, payments, and compliance-sensitive paths until equivalence is proven.
- What are the alternatives to saritasa/laravel-fluent-validation?
- Native Laravel arrays and Rule:: objects remain the default alternative, and Rule::when plus Rule::forEach cover some conditional cases without a package. You can also vendor the builder into app/Support/Validation or fork it into a private organization repository pinned to a commit. The evaluation recommends the fork-and-audit path over adding it as a floating runtime dependency.