PHPackages                             nimaebrazi/laravel-validator - 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. nimaebrazi/laravel-validator

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

nimaebrazi/laravel-validator
============================

39PHP

Since Nov 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nimaebrazi/LaravelValidator)[ Packagist](https://packagist.org/packages/nimaebrazi/laravel-validator)[ RSS](/packages/nimaebrazi-laravel-validator/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Validator
=================

[](#laravel-validator)

### Instalation

[](#instalation)

```
composer require nimaebrazi/laravel-validator
```

If using laravel `5.4.*` and older version you nedd add service provider in `config/app.php`

```
'providers' => [
    ...
    \nimaebrazi\LaravelValidator\LaravelValidatorServiceProvider::class,
    ...
]
```

Publish config:

```
php artisan vendor:publish
```

You can change message path file in config: `laravel_validator.php`

Add this key in `messages.php` file: `resources/lang/YOUR_LANGUAGE/messages.php`

```
"validation_failed" => "messages.validation_failed"
```

This package throws an exception named `ValidationException`. For handling Laravel Exception, add below code in `Handler.php` file and custumize it for your project.

```
use nimaebrazi\LaravelValidator\src\Validator\ValidationException;
use Symfony\Component\HttpFoundation\Response;

...
/**
* Render an exception into an HTTP response.
*
* @param  \Illuminate\Http\Request  $request
* @param  \Exception  $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
    if($exception instanceof ValidationException){
        return response()->json([
            'status' => Response::HTTP_UNPROCESSABLE_ENTITY,
            'description' => $exception->getMessage(),
            'data' => [
                'errors' => $exception->getErrors()
            ]

        ], 422);
    }

  return parent::render($request, $exception);
}
```

### Usage

[](#usage)

Step 1:

Create a validation class:

`\nimaebrazi\LaravelValidator\Validator\AbstractValidator`

`public function messages(): array`&amp; `public function customAttributes(): array`methods are optional.

```
use nimaebrazi\LaravelValidator\Validator\AbstractValidator;

class UpdateUserProfile extends AbstractValidator
{
    /**
     * Rules of validation.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'name' => 'required|min:3',
        ];
    }

    // OPTIONAL
    /**
     * Messages of rules.
     *
     * @return array
     */
    public function messages(): array
    {
        return [
            //
        ];
    }

    // OPTIONAL
    /**
     * Custom attributes of rules.
     *
     * @return array
     */
    public function customAttributes(): array
    {
        return [
            //
        ];
    }
}
```

#### For more about:

[](#for-more-about)

[Custom Error Messages](https://laravel.com/docs/5.7/validation#custom-error-messages)

[Custom Attributes](https://gilbitron.me/blog/laravel-custom-validation-attributes)

Step 2: Inject class to a controller:

```
class ApiUserController extends Controller
{
    /**
     * @param Request $request
     * @param UpdateUserProfile $validator
     * @throws \Exception
     * @throws \nimaebrazi\LaravelValidator\src\Validator\ValidationException
     */
    public function update(Request $request, UpdateUserProfile $validator)
    {
        $validator->make($request->all())->validate();
    }
```

#### Notes:

[](#notes)

- When you call `validate` function package throws default exception. If you want handle other way:

```
class ApiUserController extends Controller
{
    /**
     * @param Request $request
     * @param UpdateUserProfile $validator
     * @throws \Exception
     * @throws \nimaebrazi\LaravelValidator\src\Validator\ValidationException
     */
    public function update(Request $request, UpdateUserProfile $validator)
    {
        $validator->make($request->all());

        if($validator->fails()){
           // your codes
        }

        if($validator->passes()){
           // your codes
        }
    }
```

### RuleManager Helper

[](#rulemanager-helper)

Are you see document when use validator rules? I think it is so hard, when forget a rule and parameters. You can use RuleManager of this package.

```
use nimaebrazi\LaravelValidator\Validator\AbstractValidator;

class UpdateUserProfile extends AbstractValidator
{
    /**
     * Rules of validation.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'name'  => $this->ruleManager()->required()->min('3')->make(),
            'age'   => $this->ruleManager()->required()->numeric()->max('3')->min('0')->make(),
            'other' => $this->ruleManager()->required()->string()->make()
        ];
    }
}
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12497401?v=4)[Nima Ebrazi](/maintainers/nimaebrazi)[@nimaebrazi](https://github.com/nimaebrazi)

---

Top Contributors

[![nimaebrazi](https://avatars.githubusercontent.com/u/12497401?v=4)](https://github.com/nimaebrazi "nimaebrazi (36 commits)")

---

Tags

laravellaravel-packagelaravel-validationvalidation

### Embed Badge

![Health badge](/badges/nimaebrazi-laravel-validator/health.svg)

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

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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