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

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

koine/validator
===============

Validation adapter

0.9.0(11y ago)016MITPHPPHP &gt;=5.3.3

Since Sep 26Pushed 10y agoCompare

[ Source](https://github.com/koinephp/Validator)[ Packagist](https://packagist.org/packages/koine/validator)[ RSS](/packages/koine-validator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

Koine Validator
---------------

[](#koine-validator)

Validator adapter for letting you use whathever awesome validation lib you want.

Code information:

[![Build Status](https://camo.githubusercontent.com/8c931f27fc335c6be44b3c5eb939765023569776c1e272894cd70db1a1cd7131/68747470733a2f2f7472617669732d63692e6f72672f6b6f696e657068702f56616c696461746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/koinephp/Validator)[![Coverage Status](https://camo.githubusercontent.com/078c3347dddc86523590002c698c5087ca760154bfbe4bd390b55ad4e6acbeff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b6f696e657068702f56616c696461746f722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/koinephp/Validator?branch=master)[![Code Climate](https://camo.githubusercontent.com/bffab3e3e9621b51ecac2d2aed65073243a36e826e7dad135954cb484c1f77e5/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b6f696e657068702f56616c696461746f722e706e67)](https://codeclimate.com/github/koinephp/Validator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/968b743468cf3c7394d8f072b908ae96d3c4ab61f39b008758a88c77ecb92f46/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f696e657068702f56616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/koinephp/Validator/?branch=master)

Package information:

[![Latest Stable Version](https://camo.githubusercontent.com/c507aceb8606566cd79ce5a74b8567dfb0cf95035019040229df24fe91e1225c/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f76616c696461746f722f762f737461626c652e737667)](https://packagist.org/packages/koine/validator)[![Total Downloads](https://camo.githubusercontent.com/ff1c22e623ad02201fc96f8db4a84b9a27c484d9653c33628e13d6fe6dd54797/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f76616c696461746f722f646f776e6c6f6164732e737667)](https://packagist.org/packages/koine/validator)[![Latest Unstable Version](https://camo.githubusercontent.com/c62bdbdf5253d37262f85848ed725285088fe52b2e146701f460232f97b4143d/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f76616c696461746f722f762f756e737461626c652e737667)](https://packagist.org/packages/koine/validator)[![License](https://camo.githubusercontent.com/462386987be8a9603f7f5e3d8f23fdc4c15541aa84a2472904efc14d098f1ad4/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f76616c696461746f722f6c6963656e73652e737667)](https://packagist.org/packages/koine/validator)[![Dependency Status](https://camo.githubusercontent.com/f5e55cf27dc5a367b5f7ae46a9557c670bc0790266cec1db6d3386d91673baf0/68747470733a2f2f67656d6e617369756d2e636f6d2f6b6f696e657068702f56616c696461746f722e706e67)](https://gemnasium.com/koinephp/Validator)

### Usage

[](#usage)

In order to create a validator, extend the `executeValidation` method:

```
class UserValidator extends Validator
{
    /**
     * {@inheritdocs}
     */
    protected function executeValidation($value)
    {
        if (!isset($value['name'])) {
            $this->getErrors()->add('name', 'you must set name');
        } elseif (!$value['name']) {
            $this->getErrors()->add('name', 'name cannot be empty');
        }

        if (!isset($value['lastName'])) {
            $this->getErrors()->add('lastName', 'you must set last name');
        } elseif (!$value['lastName']) {
            $this->getErrors()->add('lastName', 'last name cannot be empty');
        }
    }
}

$user = array(
    'name'     => 'Jon',
    'lastName' => '',
);

$validator = new UserValidator();
$validator->isValid($user); // false

$validator->getErrors()->toArray();
// array('lastName' => array('last name cannot be empty'))

$user['lastName'] = 'Doe';

$validator->isValid($user); // true
```

If you also want to validate type of value, you can delegate validation to a typed method:

```
class UserValidator extends Validator
{
    /**
     * {@inheritdocs}
     */
    protected function executeValidation($value)
    {
        $this->validateUser($value);
    }

    private function validateUser(array $user)
    {
        if (!isset($user['name'])) {
            $this->getErrors()->add('name', 'you must set name');
        } elseif (!$user['name']) {
            $this->getErrors()->add('name', 'name cannot be empty');
        }

        if (!isset($user['lastName'])) {
            $this->getErrors()->add('lastName', 'you must set last name');
        } elseif (!$user['lastName']) {
            $this->getErrors()->add('lastName', 'last name cannot be empty');
        }
    }
}
```

### Installing

[](#installing)

#### Via Composer

[](#via-composer)

Append the lib to your requirements key in your composer.json.

```
{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/validator": "~0.9.0"
    }
}
```

### Alternative install

[](#alternative-install)

- Learn [composer](https://getcomposer.org). You should not be looking for an alternative install. It is worth the time. Trust me ;-)
- Follow [this set of instructions](#installing-via-composer)

### Issues/Features proposals

[](#issuesfeatures-proposals)

[Here](https://github.com/koinephp/Validator/issues) is the issue tracker.

Contributing
------------

[](#contributing)

Please refer to the [contribuiting guide](https://github.com/koinephp/Validator/blob/master/CONTRIBUTING.md).

### Lincense

[](#lincense)

[MIT](MIT-LICENSE)

### Authors

[](#authors)

- [Marcelo Jacobus](https://github.com/mjacobus)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

4297d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/226834?v=4)[Marcelo Jacobus](/maintainers/mjacobus)[@mjacobus](https://github.com/mjacobus)

---

Top Contributors

[![mjacobus](https://avatars.githubusercontent.com/u/226834?v=4)](https://github.com/mjacobus "mjacobus (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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