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

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

xervice/validator
=================

2.1.0(7y ago)0671MITPHPPHP &gt;=7.1.0

Since Apr 27Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (7)Used By (1)

Validator
=========

[](#validator)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ce95a8746ca6e15c09210b0d95dd83dcddb66d90e82f89d88afd7508f14a6b5c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786572766963652f76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xervice/validator/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/efeb5343c700b0c9e098b1d1573cbcf419af6f2405618851ef09e3de4e553bf7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f786572766963652f76616c696461746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xervice/validator/?branch=master)

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

[](#installation)

```
composer require xervice/validator

```

Using
-----

[](#using)

To use the configurator you have to define validator-configuration plugins.

```
use Xervice\Validator\Business\Dependency\ValidatorConfigurationProviderPluginInterface;
use Xervice\Validator\Business\Model\ValidatorType\IsType;

class TestValidatorConfig implements ValidatorConfigurationProviderPluginInterface
{
    /**
     * @return array
     */
    public function getValidatorConfiguration(): array
    {
        return [
           'unit',
           'floatTest',
           'child',
           [
               'unit' => [
                   'type' => IsType::TYPE_INTEGER
               ],
               'floatTest' => [
                   'type' => IsType::TYPE_FLOAT
               ]
           ],
           [
               'isTest' => [
                   'required' => true,
                   'type' => IsType::TYPE_BOOLEAN
               ]
           ],
           [
               'floatTest' => function ($value) {
                   return $value === 1.23;
               },
               'child' => [
                   'subchild1',
                   'subchild2' => [
                       'type' => IsType::TYPE_OBJECT
                   ],
                   'subchild3' => [
                       'type' => IsType::TYPE_BOOLEAN
                   ]
               ]
           ],
           [
               'child.*' => function ($value) {
                   return (is_string($value) || is_object($value));
               }
           ]
       ];
    }
}
```

The configuration is defined as an array. If one entry is a value "keyname" without key, you define this key as required. Also you can define the keyname as an array with the parameter "required" and "type" to define a specific value for the given key. For nested arrays you can direct address to a child value with level1.level2.level3 or you can define values for all elements like level1.level2.\* =&gt; \[ level3 =&gt; \[ type =&gt; 'integer'\] \]. For custom validations you can define a closure for one keyname. You get the value as an parameter in your closure.

Extending
---------

[](#extending)

You can write own Validator-Plugins and configure them in the validator dependency provider. Your plugin must implement the interface \\Xervice\\Validator\\Business\\Dependency\\ValidatorTypePluginInterface.

```
class ExamplePlugin extends AbstractBusinessPlugin implements ValidatorTypePluginInterface
{
    protected const NAME = 'ExamplePlugin';

    /**
     * @return string
     */
    public function getTypeName(): string
    {
        return static::NAME;
    }

    /**
     * @param mixed $config
     *
     * @return bool
     */
    public function isResponsible($config): bool
    {
        return true;
    }

    /**
     * @param array $data
     * @param string $key
     * @param mixed $config
     */
    public function validate(array $data, string $key, $config): void
    {
        if () {
            throw new ValidatorException('Foo is not valid because!');
        }
    }
}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

6

Last Release

2618d ago

Major Versions

1.2.0 → 2.0.02019-05-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ba15174c6a847524e2118ff1b34670252159fa2bee234292381e090e3f1b3a1?d=identicon)[mibexx](/maintainers/mibexx)

---

Top Contributors

[![mibexx](https://avatars.githubusercontent.com/u/12134020?v=4)](https://github.com/mibexx "mibexx (11 commits)")

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[chaoswey/taiwan-id-validator

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

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

PHPackages © 2026

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