New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

tbence/validate

Automatic validation for laravel models.
55
Install
composer require tbence/validate
Latest Version:v0.2.2
PHP:>=7.0
Laravel:5
License:MIT
Last Updated:Sep 1, 2017
Links: GitHub  ·  Packagist
Maintainer: tbence

Laravel-Validate

Total Downloads Latest Stable Version License

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.

Installation

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,

Usage

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.

Warning

This package is still in early in development use it at your own risk!

Related Packages

engency/laravel-model-validation

Model validation for Laravel projects

2,870 0
spajz/modval

Simple model validation for Laravel 4.

12 1
theriddleofenigma/laravel-model-validation

Effortless, self-contained validation for your Eloquent models.

14,121 33
usmanhalalit/dryval

Simplify validation in Laravel.

4,679 39
kharanenka/oc-model-custom-validation-message

Trait help to set custom message for model validation

63 3

Version History

Version Released PHP Laravel License
v0.2.2 >=7.0 5.5.* MIT
v0.2.1 >=7.0 5.5.* MIT
v0.2.0 >=7.0 5.5.* MIT
v0.1.4 MIT
v0.1.3 MIT