PHPackages                             flysquare/php-input-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. flysquare/php-input-validation

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

flysquare/php-input-validation
==============================

A lightweight PHP library for simple and effective data validation.

v1.0.0(1y ago)24MITPHP

Since Sep 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/FlySquare/php-input-validation)[ Packagist](https://packagist.org/packages/flysquare/php-input-validation)[ RSS](/packages/flysquare-php-input-validation/feed)WikiDiscussions master Synced 1mo ago

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

PHP Input Validation Library
============================

[](#php-input-validation-library)

This is a simple PHP library that validates user input based on predefined rules. It supports multiple validation methods such as required fields, string lengths, matching fields, email format, numeric values, and many others.

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

[](#installation)

You can install this library via [Composer](https://getcomposer.org/).

### Install via Composer

[](#install-via-composer)

```
composer require flysquare/php-input-validation
```

### Manual Installation

[](#manual-installation)

1. Clone this repository or download the `Validator.php` file.
2. Include the `Validator.php` file in your project.

```
require_once 'Validator.php';
```

Usage
-----

[](#usage)

### Initial Setup

[](#initial-setup)

Create an instance of the `Validator` class by passing the rules and data to be validated:

```
use PHPInputValidation\Validator;

$rules = [
    'name' => 'required|min:3|max:20',
    'email' => 'required|email',
    'password' => 'required|min:6',
    'confirm_password' => 'same:password'
];

$data = [
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'password' => 'password123',
    'confirm_password' => 'password123'
];

$validator = new Validator($rules, $data);
if ($validator->validate()) {
    // Validation passed
} else {
    // Validation failed
    print_r($validator->errors());
}
```

### Supported Validation Rules

[](#supported-validation-rules)

- `required`: The field must not be empty.
- `min:n`: The field must have at least `n` characters.
- `max:n`: The field must have at most `n` characters.
- `same:field`: The field must match the given `field`.
- `email`: The field must be a valid email address.
- `url`: The field must be a valid URL.
- `numeric`: The field must be numeric.
- `integer`: The field must be an integer.
- `between:min,max`: The field must be between the given minimum and maximum values.
- `alpha_num`: The field must be alphanumeric.
- `starts_with:value`: The field must start with the given value.
- `ends_with:value`: The field must end with the given value.
- `distinct`: The field must contain distinct values (for arrays).
- `json`: The field must be a valid JSON string.

### Error Handling

[](#error-handling)

The `errors()` method returns an array of validation errors:

```
$errors = $validator->errors();
print_r($errors);
```

Each field's errors will be stored under the corresponding field name in the errors array.

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for more details.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/772e379f25da19fde41cae67b77bb94825201dc3b51f202113dcaf55d17df3e3?d=identicon)[flysquare](/maintainers/flysquare)

---

Top Contributors

[![FlySquare](https://avatars.githubusercontent.com/u/47474804?v=4)](https://github.com/FlySquare "FlySquare (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flysquare-php-input-validation/health.svg)

```
[![Health](https://phpackages.com/badges/flysquare-php-input-validation/health.svg)](https://phpackages.com/packages/flysquare-php-input-validation)
```

###  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)
