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

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

yosmanyga/validation
====================

Provides tools to validate variables

0110PHP

Since Jan 31Pushed 9y ago1 watchersCompare

[ Source](https://github.com/yosmanyga/validation)[ Packagist](https://packagist.org/packages/yosmanyga/validation)[ RSS](/packages/yosmanyga-validation/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Validation
==========

[](#validation)

This library provides tools for validating simple values, arrays and objects.

You can validate a simple value by using the `ScalarValidator`:

```
// Validates that the value is an integer and is greater than 10
$validator = new ScalarValidator(array(
    'type' => 'integer',
    'gt' => 10
));
$errors = $validator->validate(9);
foreach ($errors as $error) {
    echo $error;
    echo "\r\n";
}

```

You can validate an array by using the `ArrayValidator`:

```
// Validates that a value is an array and keys must fit these requirements:
// key1 and key2 are required
// key3 is optional
// key4 is denied
$validator = new ArrayValidator(array(
    'requiredKeys' => array('key1', 'key2'),
    'allowedKeys' => array('key3'),
    'deniedKeys' => array('key4')
));
$errors = $validator->validate(array('key1' => 'foo1'));

```

You can validate an object by using the `ObjectValidator`:

```
$user = new User();
$user->name = 'John';
$user->age = 30;

// Validates that the property 'name' is a string
// and the property 'age' is an integer and is greater than 0
$validator = new ObjectValidator(array(
    'name' => new ScalarValidator(array(
        'type' => 'string'
    )),
    'age' => new ScalarValidator(array(
        'type' => 'integer'
        'gt' => 0
    ))
));
$errors = $validator->validate($user);

```

Documentation
=============

[](#documentation)

Read the documentation for more information.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

[![yosmanyga](https://avatars.githubusercontent.com/u/237282?v=4)](https://github.com/yosmanyga "yosmanyga (62 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

### Embed Badge

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

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

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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