PHPackages                             wamesk/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. [API Development](/categories/api)
4. /
5. wamesk/laravel-validator

ActiveLibrary[API Development](/categories/api)

wamesk/laravel-validator
========================

Laravel extended validator.

0.1.0(2y ago)0172MITPHPPHP ^8.0|^8.1|^8.2

Since Sep 19Pushed 2y ago2 watchersCompare

[ Source](https://github.com/wamesk/laravel-validator)[ Packagist](https://packagist.org/packages/wamesk/laravel-validator)[ RSS](/packages/wamesk-laravel-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

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

[](#laravel-validator)

Laravel package that extends default laravel validator
------------------------------------------------------

[](#laravel-package-that-extends-default-laravel-validator)

- [Laravel Validator](#laravel-validator)
    - [Laravel package that extends default laravel validator](#laravel-package-that-extends-default-laravel-validator)
    - [Installation](#installation)
    - [Validator](#validator)
        - [Validate function](#validate-function)
        - [Code function](#code-function)
        - [Messages function](#messages-function)
        - [Status Code function](#status-code-function)
    - [Rules](#rules)
        - [Exists rule](#exists-rule)
        - [IsInteger rule](#isinteger-rule)
        - [IsString rule](#isstring-rule)
        - [IsArray rule](#isarray-rule)

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

[](#installation)

```
composer require wamesk/laravel-validator
```

**Publish translations**

```
php artisan vendor:publish --provider="Wame\Validator\LaravelValidatorServiceProvider" --tag="translations"
```

Validator
---------

[](#validator)

Validator used by default in this package. It works by chaining functions and getting response. Response is generated by `wamesk/laravel-api-response` package functions. To better understand how response works checkout documentation for response package [here](https://github.com/wamesk/laravel-api-response)

### Validate function

[](#validate-function)

This function is final function. Always last. It requires data and rules for validation. Documentation for rules [click here](https://laravel.com/docs/9.x/validation)

Usage example:

```
$data = ['email' => 'example@gmail.com', 'password' => 'password'];

$validator = Validator::validate($data, [
    'email' => 'email|required|max:255',
    'password' => 'required|string'
]);
if ($validator) return $validator;
```

In case of validation error it will return

```
{
    "data": null,
    "code": null,
    "errors": {
        "email": [
            "validation.required"
        ]
    },
    "message": null
}
```

### Code function

[](#code-function)

This function is add internal code in response. You can pass second parameter that changes prefix for message translation.

Usage example:

```
$data = ['email' => 'example@gmail.com', 'password' => 'password'];

$validator = Validator::code('1.2')->validate($data, [
    'email' => 'email|required|max:255',
    'password' => 'required|string'
]);
if ($validator) return $validator;
```

In case of validation error it will return

```
{
    "data": "1.2",
    "code": null,
    "errors": {
        "email": [
            "The email field is required"
        ]
    },
    "message": "api.1.2"
}
```

### Messages function

[](#messages-function)

This function adds custom response for validation. You need to pass objects of which key is field, and it's validation. As value, you pass your custom message as shown in example.

Usage example:

```
$data = ['email' => 'example@gmail.com', 'password' => 'password'];

$validator = Validator::code('1.2')
    ->messages([
        'email.required' => 'Email is required'
    ])
    ->validate($data, [
        'email' => 'email|required|max:255',
        'password' => 'required|string'
    ]);
if ($validator) return $validator;
```

In case of validation error it will return

```
{
    "data": "1.2",
    "code": null,
    "errors": {
        "email": [
            "Email is required"
        ]
    },
    "message": "api.1.2"
}
```

### Status Code function

[](#status-code-function)

This function doesn't change response visually but changes status code of response. Default status code is 400 *(Bad Request)*. If you want to chain all functions it can look like this. Status code is always integer.

```
Validator::statusCode($statusCode)->code($code)->messages($messages)->validate($data, $rules);
```

Rules
-----

[](#rules)

This package also provides you with these custom rules for your project.

Usage:

```
Validator::code($code)->validate($data, [
    'id' => [
        new Exists(User::class),
    ]
]);
```

### Exists rule

[](#exists-rule)

This rule validates if entity exists. It requires model class in construct. Firstly it validates if there is entity with this parameter in database. Secondly it checks if it wasn't deleted, if it was it returns validation error. You can pass second *(optional)* parameter *column name*.

```
new \Wame\Validator\Rules\Exists(User::class, 'id')
```

### IsInteger rule

[](#isinteger-rule)

This rule validates if attribute is integer. You can pass additional data (min, max) in construct to create range of acceptable integers.

```
new \Wame\Validator\Rules\IsInteger(min: 10, max: 100)
```

### IsString rule

[](#isstring-rule)

This rule validates if attribute is string. You can pass additional data (min, max) to validate length of string.

```
new \Wame\Validator\Rules\IsString(min: 10, max: 100)
```

### IsArray rule

[](#isarray-rule)

This rule validates if attribute is array. You can pass additional data (min, max) to validate length of array.

```
new \Wame\Validator\Rules\IsString(min: 10, max: 100)
```

### IsEmail rule

[](#isemail-rule)

Validates email format, checks domain existence, and optionally blocks temporary email domains in Laravel. You can pass additional data (true, false) to enable some functions.

```
new \Wame\Validator\Rules\IsEmail(domainMustExist: false, disableTempMail: false)
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

963d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bf6ece61ae07942df38ce88eb4053d4176c6ab0bf803191953961023f25fc70?d=identicon)[WAME](/maintainers/WAME)

---

Top Contributors

[![adrianzofcin](https://avatars.githubusercontent.com/u/75702986?v=4)](https://github.com/adrianzofcin "adrianzofcin (15 commits)")[![DavidPuzder](https://avatars.githubusercontent.com/u/36508590?v=4)](https://github.com/DavidPuzder "DavidPuzder (1 commits)")

---

Tags

responseapilaravelhelper

### Embed Badge

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

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M111](/packages/darkaonline-l5-swagger)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[vinelab/api-manager

Laravel API Manager Package - beatify and unify your responses with the least effort possible.

392.1k](/packages/vinelab-api-manager)

PHPackages © 2026

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