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

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

satanvir/validator
==================

A PHP package that allows you to handling form request validation.

02PHP

Since May 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/satanvir5/request-validator)[ Packagist](https://packagist.org/packages/satanvir/validator)[ RSS](/packages/satanvir-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

About Validator
---------------

[](#about-validator)

A PHP package that allows you to handling form request validation.

Requirements
------------

[](#requirements)

- PHP "^8.0"

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

[](#installation)

You can install the package via composer:

```
composer require satanvir/validator
```

Usage
-----

[](#usage)

Here's an example of how to use this Validator package for validating input reques:

```
use Satanvir\Validator\Validator;

$validator = new Validator($config); // Validator(array $config = [])
```

Passing User's Inputs
---------------------

[](#passing--users-inputs)

```
$validator->request($_POST); // Validator::request(array $inputs): self
```

Define Rules
------------

[](#define-rules)

You can define rules by two ways.

1. Bulk way
2. Single Input

### Bulk way

[](#bulk-way)

```
$rules = [
'name' => 'required|min:3|max:60',
'email' => ['required', 'email']
];

$validator->rules($rules); // Validator::rules(array $rules): self

```

### Single Input

[](#single-input)

```
$validator->rule('email', 'required|email'); // Validator::rule(string $name, array|string $rule): self

```

Validation
----------

[](#validation)

```
$validator->validate(); // Validator::validate(): self

```

\*\*\* This method validate the given inputs by using the given rules \*\*\*

### Check: Validation has failed

[](#check-validation-has-failed)

```
if ($validator->fails()) {
// do something
}
// Validator::fails(): bool

```

\*\*\* Return true if validation failed \*\*\*

### Check: Validation has passed

[](#check-validation-has-passed)

```
if ($validator->passed()) {
// do something
}
// Validator::passed(): bool

```

\*\*\* Return true if validation passed \*\*\*

Getting Errors
--------------

[](#getting-errors)

### Getting all errors

[](#getting-all-errors)

```
foreach ($validator->errors() as $error) {
// do something
}
// Validator::errors(): array

```

\*\*\* errors() method returns all generated errors from validators \*\*\*

### Getting all errors of a single input

[](#getting-all-errors-of-a-single-input)

```
foreach ($validator->error('email') as $error) {
// do something
}
// Validator::error(string $name): array

```

### Getting first error

[](#getting-first-error)

```
echo $validator->errorFirst();
//or
echo $validator->errorFirst('email');
// Validator:errorFirst(?string $name = null): ?string
```

\*\*\* if did not pass any param, then return first error from all otherwise return from specific input. \*\*\*

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

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://www.gravatar.com/avatar/725a133ca5d560fabafe8eb18ecce9596642044bcc441745dc26eb3cdc5081f8?d=identicon)[satanvir5](/maintainers/satanvir5)

### Embed Badge

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

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

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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