A Laravel Eloquent trait that automatically validates models before saving, ensuring only valid data is persisted.
Validating is a Laravel package that provides a trait for Eloquent models to automatically validate their data against defined rules before being saved to the database. It solves the problem of ensuring data integrity at the model layer, preventing invalid data from persisting and providing validation errors directly on the model instance.
Laravel developers who need to enforce data validation rules directly within their Eloquent models, especially those building applications where model data integrity is critical and should be validated independently of form input.
Developers choose Validating because it integrates model validation seamlessly into Laravel's Eloquent ORM, offers features like automatic unique rule injection and validation exceptions, and keeps validation logic close to the data model while remaining lightweight and flexible.
Automatically validating Eloquent models for Laravel
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Injects the model's ID into unique validation rules during updates, preventing conflicts without manual adjustments, as detailed in the README's section on unique rules.
Throws Laravel's ValidationException, which the framework automatically handles for redirects with errors, mirroring FormRequest behavior and simplifying error management.
Fires 'validating' and 'validated' events, allowing developers to intercept and modify validation logic, providing flexibility for custom business rules.
Includes a forceSave() method to skip validation when necessary, offering control over validation enforcement for edge cases or administrative overrides.
The README admits a Laravel bug that prevents model events from firing more than once in tests, requiring workarounds like resetting events between tests, adding setup complexity.
Maintains separate branches for different Laravel versions (e.g., 4.2+, 5.0-5.2), which can confuse developers during upgrades and increase maintenance overhead.
Only pre-configured for specific rules like Laravel's unique and felixkiss/uniquewith-validator; adding custom rule injection requires manual implementation, increasing development effort.