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

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

badelal2007/validator
=====================

PHP Validator class.

v1.0(8y ago)015BSD-3-ClausePHPPHP &gt;=5.4

Since Mar 1Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Validator
=========

[](#validator)

**Validator** is a framework agnostic and fluent server side form validation package for PHP

\[Documentation\]
=================

[](#documentation)

Installation
============

[](#installation)

Validator can be installed via `composer` just execute the following command in your project root

`composer require badelal2007/validator`

Or add the following in your composer.json file and run `composer install`

```
"require": {
    "badelal2007/validator": "dev-master"
}

```

Usage
=====

[](#usage)

Using validator in your project is super simple, here is an example

```
require_once __DIR__ . '/vendor/autoload.php';

$validator = new validator\Validator();
$validator->validate($_POST, [
    'username'         => 'required',
    'password'         => 'required|password:strong',
    'confirm_password' => 'required|same:password'
]);

#Return true if validation pass
var_dump($validator->passed());

#Return true if validation failed
var_dump($validator->failed());

#Return all errores if any
var_dump($validator->getErrors());

#Print first error if any for 'password' field
if($errors->get('password')) { echo ''.$errors->get('password')->first().''; }

#Print last error if any for 'password' field
if($errors->get('password')) { echo ''.$errors->get('password')->last().''; }

#Change 'message' for validation rule
$validator->validate($_POST, [
    'email'     => 'required--message=Please enter email|email--Please enter valid email ID.',
    'password'  => 'required'
]);
```

If you've files to validate you will need to merge `$_POST|$_GET` and with `$_FILES` just like the following

```
$validator = new validator\Validator();
$validator->validate(array_merge($_POST, $_FILES), [
    'profile_picture' => 'file:image'
]);
```

Available Rules
===============

[](#available-rules)

- required
- email
- password `Accepts password strength like password:strong|medium|normal (default noraml)`
- number
- file `Accepts file type currently supported formats: image,video,doc`
- min
- max
- length
- array
- boolean
- ip
- same
- alpha
- alnum

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2996d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e994ce93e47e72dadfdae05d6ba537b0a21d4b01804237bb0e5045aed22be90a?d=identicon)[badelal2007](/maintainers/badelal2007)

---

Top Contributors

[![badelal2007](https://avatars.githubusercontent.com/u/7411438?v=4)](https://github.com/badelal2007 "badelal2007 (15 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/badelal2007-validator/health.svg)](https://phpackages.com/packages/badelal2007-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)
