Package Data | |
---|---|
Maintainer Username: | tbence |
Maintainer Contact: | tihanyibence@gmail.com (Bence Tihanyi) |
Package Create Date: | 2017-08-30 |
Package Last Update: | 2017-09-01 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:04:14 |
Package Statistics | |
---|---|
Total Downloads: | 55 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Adds an AutoValidation trait to your project. If you use that trait on your models, it will automatically vaildate it by your DB scheme. These validation rules can be overridden manually from the model.
composer require tbence/validate
If Laravel version < 5.5, you have to manually include this line in your config/app.php:
TBence\Validate\Provider::class,
Add the trait and the interface to your model. (Procuct is just an example.)
<?php
namespace App;
use TBence\Validate\AutoValidation;
use TBence\Validate\Validates;
class Product extends Model implements Validates
{
use AutoValidation;
//...
}
That's it. If you try to create or update a Product model with data that's not compatible with your database schema
the package will throw a ValidationException which is handled by laravel automatically.
So the system will not fail with something went wrong
when you are missing a value for a not null column.
It will return with standard validation error messages instead.
For example:
The name field is required.
This package is still in early in development use it at your own risk!