phphd/exceptional-validation
Exceptional Validation brings exception-driven validation to Laravel, letting you express validation failures as exceptions handled by Laravel’s exception pipeline. Keep controllers, form requests, and domain code clean with reusable validation logic.
render() overrides per controller.Handler/Exceptions folder. This package lets you adopt a small, declarative mapping layer rather than funding an internal framework. The right comparison is "one sprint of internal plumbing + permanent maintenance" vs. "one small Composer dependency."ValidationException shape needs to be normalized alongside non-validation errors, and teams that want error mapping covered by tests rather than by convention.Adopt (or spike) when most of these hold:
switch/match in the handler is becoming a maintenance hotspot.ValidationFailedException and violation-embedding exceptions, which is exactly this need.Look elsewhere or stay with framework defaults when:
render()/report() on exception classes plus handler configuration is sufficient and adds zero dependencies. Do not add a package to solve three if statements.2.0.0-rc3. The RC cycle is explicitly rearranging internals (see below), so the public surface is not yet frozen. If you can't absorb a migration in the next quarter, wait for 2.0.0 stable.ValidationFailedException and ViolationsEmbeddedException and moves Validator/UID integration code into an Integration\ namespace. If your code imports those classes or subclasses the old formatter, plan for import updates. If you only use the documented entry points, impact is likely nil — verify before upgrading.For executives (one paragraph): Our API's error responses are currently inconsistent — each endpoint invents its own failure shape, which costs us client-side bugs, slower partner onboarding, and support time. This package gives us one declarative place to define how every failure is reported, at the cost of a single small dependency. It is low-effort, low-risk, and reversible: our error definitions stay ours, and we can remove the package without rewriting business logic. Recommended action is a timeboxed spike now, adoption after the 2.0 stable release.
For engineering: This is a declarative exception→response mapping layer, Laravel-native, with first-class handling for validation failures and embedded violation lists — the two cases where our current handler is messiest. The new 2.0.0-rc3 is refactor-only: one unified formatter for validation-failed and violations-embedded exceptions, and Validator/UID integration code relocated under an Integration\ namespace. No new features, no deprecations, no documented behavior changes. Practical guidance: pin the exact RC, keep our mapping definitions in application code rather than extending package internals, and budget a short import-path cleanup if we were reaching into Integration-adjacent classes. Upgrade to stable 2.0.0 when it lands and treat that as the point where we commit.
How can I help you explore Laravel packages today?