PHPackages                             initphp/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. initphp/validation

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

initphp/validation
==================

InitPHP Validation Library

1.0.2(3y ago)120912MITPHPPHP &gt;=7.4

Since Jul 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/InitPHP/Validation)[ Packagist](https://packagist.org/packages/initphp/validation)[ RSS](/packages/initphp-validation/feed)WikiDiscussions main Synced 1mo ago

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

InitPHP Validation
==================

[](#initphp-validation)

Simple and fast library for verifying that the data is of the type and structure you want.

[![Latest Stable Version](https://camo.githubusercontent.com/18a60d2db0cdad8b4e543ece4261cad65a7c344232739cf5dac23bc037780cd2/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f76616c69646174696f6e2f76)](https://packagist.org/packages/initphp/validation) [![Total Downloads](https://camo.githubusercontent.com/23b35b6802d8a54628808ec3f8e02ed75e08b9a160bb4c49a986ae5f6fc0d297/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f76616c69646174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/initphp/validation) [![Latest Unstable Version](https://camo.githubusercontent.com/9a3f71b76ac2f1d4ce7dd6b324bb20ebe1498680a8267cff2e678a0554fe2503/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f76616c69646174696f6e2f762f756e737461626c65)](https://packagist.org/packages/initphp/validation) [![License](https://camo.githubusercontent.com/cd8dd4eeb954463ef381c59ad22e3515d95308b6e32c42b8b2a14886c19a9a76/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f76616c69646174696f6e2f6c6963656e7365)](https://packagist.org/packages/initphp/validation) [![PHP Version Require](https://camo.githubusercontent.com/771755f96884b64a1683fe33dc340cf88e4aa5b6992f6e744fa81cc5d30f3110/687474703a2f2f706f7365722e707567782e6f72672f696e69747068702f76616c69646174696f6e2f726571756972652f706870)](https://packagist.org/packages/initphp/validation)

- [ChangeLog](./CHANGELOG.md)

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

[](#requirements)

- PHP 7.4 or higher
- PHP MB\_String Extension

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

[](#installation)

```
composer require initphp/validation

```

Validation Rules
================

[](#validation-rules)

- `integer` : Verifies that the data is an integer.
- `float` : Verifies that the data is a floating point number.
- `numeric` : Verifies that the data is a numeric value.
- `string` : Verifies that the data is of a string type.
- `boolean` : Verifies that the data has a logical value or equivalent.
- `array` : Verifies that the data is an array.
- `mail` : Verifies that the data is an E-Mail address.
- `mailHost` : Verifies that the data is the E-Mail address using the specified host.
- `url` : Verifies that the data is a URL address.
- `urlHost` : Verifies that the data is a URL of the specified host (or subdomain).
- `empty` : Verifies that the data is empty.
- `required` : Verifies that the data is not null.
- `min` : Defines the minimum value the data can have. Specifies the minimum number of elements/characters if the data is a string or array.
- `max` : Defines the maximum value the data can have. Specifies the maximum number of elements/characters if the data is a string or array.
- `length` : Verifies that the number of characters is within the specified range.
- `range` : The numeric value must be within the specified range.
- `regex` : Validates data with a predefined or postdefined regular expression.
- `date` : Attempts to verify that the data is a date.
- `dateFormat` : Verifies that the data is a date in a specified format.
- `ip` : Verifies that the data is IP address.
- `ipv4` : Verifies that the data is IPv4.
- `ipv6` : Verifies that the data is IPv6.
- `again` : Verifies that the data is the same as the value of a data key.
- `equals` : Verifies that the data is equivalent to the specified value.
- `startWith` : Verifies that the data starts with the specified value.
- `endWith` : Array or String. Verifies that the data ends with the specified value.
- `in` : Case-insensitive verifies that the specified value is in the data.
- `notIn` : Case-insensitive verifies that the specified value is not in the data.
- `contains` : Verifies that the specified case-sensitive value is in the data.
- `notContains` : Verifies that the specified case-sensitive value is not in the data.
- `alpha` : Verifies that the data is an alpha value.
- `alphaNum` : Verifies that the data is an alphanumeric value.
- `creditCard` : Verifies that the data is a credit card number.
- `only` : It validates only one of the specified values, case-insensitively.
- `strictOnly` : Case sensitive only validates that it is one of the values specified.
- `optional` : If there is data, it must obey the rules, but if there is no data with the corresponding key, the validation will not fail.

Usage
-----

[](#usage)

```
require_once "vendor/autoload.php";
use \InitPHP\Validation\Validation;

$validation = new Validation($_GET);

// GET /?name=Muhammet&year=2022

$validation->rule('name', 'string');
$validation->rule('year', 'integer|range(1970...2099)');

if($validation->validation()){
    // ... process
}else{
    foreach ($validation->getError() as $err) {
        echo $err . "\n";
    }
}
```

**Callable verification rule;**

```
require_once "vendor/autoload.php";
use \InitPHP\Validation\Validation;

$validation = new Validation($_GET);

// GET /?number=13

$validation->rule('number', function ($data) {
    if(($data % 2) == 0){
        return true;
    }
    return false;
}, "{field} must be an even number.");

if($validation->validation()){
    // ... process
}else{
    foreach ($validation->getError() as $err) {
        echo $err . "\n";
    }
}
```

***You can review the `tests/Validation/ValidationUnitTest.php` file to view sample usages.***

Getting Help
------------

[](#getting-help)

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

Getting Involved
----------------

[](#getting-involved)

> All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.

There are two primary ways to help:

- Using the issue tracker, and
- Changing the code-base.

### Using the issue tracker

[](#using-the-issue-tracker)

Use the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution.

Use the issue tracker to find ways to contribute. Find a bug or a feature, mention in the issue that you will take on that effort, then follow the Changing the code-base guidance below.

### Changing the code-base

[](#changing-the-code-base)

Generally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All new code should have associated unit tests that validate implemented features and the presence or lack of defects. Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing code-base.

Credits
-------

[](#credits)

- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) &lt;&gt;

License
-------

[](#license)

Copyright © 2022 [MIT License](./LICENSE)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

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

1413d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b6b34f3ac8938d8ee52ba3bd260680855dc5715c7b2929d9380de30d15a67dd?d=identicon)[muhammetsafak](/maintainers/muhammetsafak)

---

Top Contributors

[![muhammetsafak](https://avatars.githubusercontent.com/u/104234499?v=4)](https://github.com/muhammetsafak "muhammetsafak (2 commits)")

---

Tags

phpphp-validationphp-validatorvalidationvalidator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/initphp-validation/health.svg)

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