sourcetoad/rule-helper-for-laravel
A Laravel package that adds fluent helpers for building validation rule arrays, including RuleSet and Rule classes, reusable defined rule sets, and conditional required helpers such as requiredIfAll and requiredIfAny.
What the package actually is (scope assessment)
Illuminate\Validation. Two public surfaces: RuleSet (fluent builder, IteratorAggregate) and Rule (static mirror of Laravel's Rule facade), plus a named-set registry (RuleSet::define() / useDefined() / concatDefined()) and two composite helpers (requiredIfAll, requiredIfAny).Architecture fit
RuleSet::define() in a service provider is a global mutable registry and will drift into a "domain rules in a God service provider" anti-pattern if unowned.existing_email to be enforced across web, API, and admin surfaces. That is a quality lever a TPM can measure.Integration feasibility
composer require sourcetoad/rule-helper-for-laravel, additive, non-breaking to existing string rules. Both APIs (Rule:: static arrays and fluent RuleSet) can coexist, so adoption can be incremental per file rather than a flag-day migration.Technical risk (register view)
| Risk | Severity | Likelihood | Note |
|---|---|---|---|
| Version lock-step with Laravel majors | Medium | High | v7 dropped Laravel 12 and PHP 8.2; v6 dropped 11; v5 dropped 10. Every Laravel major forces a matching package major. |
| Being pinned off a supported Laravel/PHP line | High | Medium | If upstream stalls on a future Laravel major, the wrapper becomes the reason you cannot take framework security patches. This is the primary business risk. |
| Tooling blindness | Medium | Medium | Rule objects are opaque to string-parsing tooling — OpenAPI generators (Scramble/Knuckles-style), validation documentation, and any in_array('required', $rules) logic. Verify against your current doc pipeline before standardizing. |
| Breaking helper semantics | Low | Medium | string/integer became fluent in v7; password changed meaning in 3.2. Chained-call results may not equal prior string output. |
| Vendor concentration | Medium | High | 9 stars, 0 dependents, single maintainer. MIT license mitigates via fork rights. |
Key questions to resolve before committing
13.x → 7.x and 13.x → 6.3.x, yet 6.4.0 and 7.0.1 both exist — the matrix is ambiguous and needs confirming from composer.json constraints, not the README.Rule::/RuleSet object form degrades generated specs.ValidationRuleSetsServiceProvider, and is RuleSet::define() acceptable as a global registry in our conventions?requiredIfAll/requiredIfAny semantics (all-must-hold vs any-must-hold) actually needed, or duplicative of Laravel's native required_if composition?Stack fit
boot() is per-worker and must be idempotent).Migration path (incremental, reversible)
ValidationRuleSetsServiceProvider; naming scheme for defined sets; prohibition on mixing string rules and helper calls within the same field to avoid confusing rule ordering.->required()/->max(n) cases. Do not attempt a big-bang rewrite; the conversion has no functional payoff per file.Compatibility and versioning
Sequencing (relative, no calendar dates)
| Order | Activity | Gate |
|---|---|---|
| 1 | Confirm Laravel/PHP version and correct package major from composer.json |
Compatibility matrix ambiguity resolved |
| 2 | Pilot conversion in one module | Behavior parity on existing tests |
| 3 | Tooling check (OpenAPI/static analysis) | No degraded generated artifacts |
| 4 | Conventions doc + provider + lint guardrail | Team sign-off |
| 5 | Opportunistic rollout | Adoption tracked |
Rollback
Maintenance
date/email/file/image; v7 string/integer).Support
composer.lock pinned and vendor the package if a fork becomes necessary; do not rely on upstream responsiveness for a security-relevant framework bump.Scaling
Failure modes to monitor
['required','max:255','unique:posts'] to a chain can reorder; bail-less validation reports multiple errors, so reordering rarely breaks function but can change user-facing error text and any tests asserting message order.required/format constraints after objects replace strings, which is a documentation/compliance exposure rather than a runtime one.Ramp-up
RuleSet behavior as authoritative over Laravel's documented rule semantics.Recommendation (TPM posture)
How can I help you explore Laravel packages today?