tbence/validate is a Laravel package for automatic validation for laravel models..
It currently has 0 GitHub stars and 55 downloads on Packagist (latest version v0.2.2).
Install it with composer require tbence/validate.
Discover more Laravel packages by tbence
or browse all Laravel packages to compare alternatives.
Last updated
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!