PHPackages                             lfml/laravel-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. lfml/laravel-validation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

lfml/laravel-validation
=======================

Laravel Validation Service

1.1.1(6y ago)0221PHPPHP &gt;=7.1

Since May 29Pushed 6y agoCompare

[ Source](https://github.com/LFML/laravel-validation)[ Packagist](https://packagist.org/packages/lfml/laravel-validation)[ Docs](http://lfml.github.io/laravel-validation)[ RSS](/packages/lfml-laravel-validation/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (3)Used By (1)

Laravel Validation Service
==========================

[](#laravel-validation-service)

[![Total Downloads](https://camo.githubusercontent.com/0f252024417a63c2cb3d7952113ca6122f6eb30849d77a42b6d9671a7effefa6/68747470733a2f2f706f7365722e707567782e6f72672f707265747475732f6c61726176656c2d76616c69646174696f6e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/prettus/laravel-validation)[![Latest Stable Version](https://camo.githubusercontent.com/5a58e04fc9e1c5329c8966d3a7aa64d1eb7891fab0c916800e41d27f5786812f/68747470733a2f2f706f7365722e707567782e6f72672f707265747475732f6c61726176656c2d76616c69646174696f6e2f762f737461626c652e737667)](https://packagist.org/packages/prettus/laravel-validation)[![Latest Unstable Version](https://camo.githubusercontent.com/ea4e13289509c7bab8ab905aeff89903dd344b7c41e8220ccda2d058bcba7c4f/68747470733a2f2f706f7365722e707567782e6f72672f707265747475732f6c61726176656c2d76616c69646174696f6e2f762f756e737461626c652e737667)](https://packagist.org/packages/prettus/laravel-validation)[![License](https://camo.githubusercontent.com/c47050b9e7e2815d29279f34b9dbb78a5c0e5365362cfb923389d7c1fba4b955/68747470733a2f2f706f7365722e707567782e6f72672f707265747475732f6c61726176656c2d76616c69646174696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/prettus/laravel-validation)

Installation
------------

[](#installation)

Add "lfml/laravel-repository": "1.1.\*" to composer.json

```
"prettus/laravel-validation": "1.1.*"
```

### Create a validator

[](#create-a-validator)

The Validator contains rules for adding, editing.

```
Prettus\Validator\Contracts\ValidatorInterface::RULE_CREATE
Prettus\Validator\Contracts\ValidatorInterface::RULE_UPDATE
```

In the example below, we define some rules for both creation and edition

```
use \Prettus\Validator\LaravelValidator;

class PostValidator extends LaravelValidator {

    protected $rules = [
        'title' => 'required',
        'text'  => 'min:3',
        'author'=> 'required'
    ];

}
```

To define specific rules, proceed as shown below:

```
use \Prettus\Validator\LaravelValidator;

class PostValidator extends LaravelValidator {

    protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'title' => 'required',
            'text'  => 'min:3',
            'author'=> 'required'
        ],
        ValidatorInterface::RULE_UPDATE => [
            'title' => 'required'
        ]
   ];

}
```

### Custom Error Messages

[](#custom-error-messages)

You may use custom error messages for validation instead of the defaults

```
protected $messages = [
    'required' => 'The :attribute field is required.',
];
```

Or, you may wish to specify a custom error messages only for a specific field.

```
protected $messages = [
    'email.required' => 'We need to know your e-mail address!',
];
```

### Custom Attributes

[](#custom-attributes)

You too may use custom name attributes

```
protected $attributes = [
    'email' => 'E-mail',
    'obs' => 'Observation',
];
```

### Using the Validator

[](#using-the-validator)

```
use \Prettus\Validator\Exceptions\ValidatorException;

class PostsController extends BaseController {

    /**
     * @var PostRepository
     */
    protected $repository;

    /**
     * @var PostValidator
     */
    protected $validator;

    public function __construct(PostRepository $repository, PostValidator $validator){
        $this->repository = $repository;
        $this->validator  = $validator;
    }

    public function store()
    {

        try {

            $this->validator->with( Input::all() )->passesOrFail();

            // OR $this->validator->with( Input::all() )->passesOrFail( ValidatorInterface::RULE_CREATE );

            $post = $this->repository->create( Input::all() );

            return Response::json([
                'message'=>'Post created',
                'data'   =>$post->toArray()
            ]);

        } catch (ValidatorException $e) {

            return Response::json([
                'error'   =>true,
                'message' =>$e->getMessage()
            ]);

        }
    }

    public function update($id)
    {

        try{

            $this->validator->with( Input::all() )->passesOrFail( ValidatorInterface::RULE_UPDATE );

            $post = $this->repository->update( Input::all(), $id );

            return Response::json([
                'message'=>'Post created',
                'data'   =>$post->toArray()
            ]);

        }catch (ValidatorException $e){

            return Response::json([
                'error'   =>true,
                'message' =>$e->getMessage()
            ]);

        }

    }
}
```

Author
======

[](#author)

Anderson Andrade -

Credits
-------

[](#credits)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2538d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8600a92fff164d599e2637453dd42fec7ea4530f6d2a7373fdcfe399e77b5dab?d=identicon)[luisml-lfml](/maintainers/luisml-lfml)

---

Tags

laravelvalidationservice

### Embed Badge

![Health badge](/badges/lfml-laravel-validation/health.svg)

```
[![Health](https://phpackages.com/badges/lfml-laravel-validation/health.svg)](https://phpackages.com/packages/lfml-laravel-validation)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M106](/packages/propaganistas-laravel-phone)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[prettus/laravel-validation

Laravel Validation Service

40710.8M52](/packages/prettus-laravel-validation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
