Product Decisions This Supports
- Build vs. buy for validation placement. The package answers a recurring architectural question — where do validation rules live? — by letting rules be declared directly on the Eloquent model and enforced automatically on chosen model events. That makes "buy" (adopt a small MIT trait, ~hours of integration) competitive with "build" (write your own trait, ~days) for teams standardizing on Laravel 12/13.
- Data integrity as a product guarantee, not just an HTTP concern. Today most Laravel apps validate only at the edge (FormRequests/controllers). Any write path that bypasses HTTP — queued jobs, Artisan commands, CSV imports, seeders, admin panels, Tinker, partner API ingestion — silently skips those rules. Model-level validation closes that gap, so the product decision becomes: do we guarantee invariants everywhere data is written?
- Feature scoping and roadmap sequencing. Because the integration surface is a single trait plus per-model rule declarations, this is an incremental, reversible roadmap item rather than a migration project. It fits well as a "quality/hardening" sprint item alongside test coverage, not as an architecture rewrite.
- Consolidating duplicated rules. Teams frequently maintain the same rule set in a FormRequest and a model accessor/service. Choosing one home for rules reduces drift bugs and review overhead — a measurable maintenance win.
- Use cases that justify adoption: multi-entry-point products (web + API + mobile + import pipelines) writing to the same tables; internal tools and back-office CRUD built quickly without FormRequest ceremony; domain-heavy apps where a model is the natural owner of its constraints.
- Explicitly not a substitute for request-layer validation. Rules that depend on request context (authorization,
confirmed, file uploads, cross-field input shaping, user-scoped uniqueness with request data) still belong in FormRequests. Position this as a backstop for domain invariants, with HTTP validation retained for UX.
When to Consider This Package
Adopt when most of the following hold:
- You are on Laravel 12.x or 13.x and PHP 8.2+ — the package supports nothing older, and EOL Laravel versions are out of scope.
- Your writes reach the database through Eloquent models and you can rely on model events firing. Bulk operations (
DB::table() inserts, ->update() on a query builder, upsert, truncation) do not trigger model events, so this cannot be your only integrity control in bulk-import-heavy systems.
- Your rule sets are model-local and reasonably simple (required/present, types, ranges, uniqueness, formats). Complex conditional graphs, heavy
Rule::when composition, or message-heavy multilingual UX still read better in FormRequests.
- You want validation on non-HTTP write paths and are currently relying on discipline or duplicated checks.
- You value low exit cost: MIT license, a trait you can vendor or reimplement, no service-provider lock-in, no data migration. Worst case is a fork or copy-paste.
- You have someone who can pin a version and watch releases — this is a low-adoption package (33 stars, 0 dependents), so treat it as a dependency you own, not one the community stress-tests for you.
Look elsewhere (or build in-house) when:
- You need validation on Laravel 11 or older, or PHP 8.1.
- Your architecture already centralizes invariants in a domain/service layer or database constraints, and adding model-event validation would duplicate that.
- You need mature ecosystem support: extensive documentation, community answers, third-party integrations, or confidence in a multi-maintainer team. With effectively zero dependents, you are an early adopter.
- Performance is critical on high-volume writes — model event hooks and per-save validation add overhead; benchmark against your hot paths before committing.
- You need authorization, request shaping, or file validation co-located with rules — keep a FormRequest strategy.
- Your team is uncomfortable with single-maintainer risk and the release cadence (recent, forward-looking support for Laravel 13) outweighs that concern only if you're willing to fork on abandonment.
Mitigations to require before adoption: pin the version in composer.json, add a test suite covering your declared rules, document the trait in your onboarding notes, and record a "fork if abandoned" decision owner.
How to Pitch It (Stakeholders)
To executives: This is a small, cheap hardening of data quality across every way data enters our product — not just the web form. It's an MIT-licensed library with a tiny integration surface (one trait, rules declared on models), so cost is measured in hours, not sprints, and the exit cost is near zero since we can vendor or reimplement it. The business outcome is fewer bad rows, fewer "why did this record save?" incidents, and consistent behavior for API, import, and internal-tool write paths. Principal risk is maintainer concentration in a young package; we mitigate with version pinning, our own tests, and a fork plan.
To engineering: Add the trait to models where invariants genuinely belong to the model, declare rules there, and opt in to the specific events you care about. Keep FormRequests for HTTP-specific concerns (authorization, request-shaped input, uploaded files) — this is a backstop, not a replacement. Note the hard boundary: query-builder and bulk writes bypass model events, so bulk importers need their own validation path. Requires Laravel 12/13 and PHP 8.2+. Start with one high-traffic model, measure, then expand.
Recommendation: Pilot on one or two models in a non-critical path, keep request-layer validation intact, and revisit broader rollout after a release cycle of observation. Treat adoption as conditional go — value is real but the package's maturity profile means we own the risk.