PHPackages                             suomec/ovalidator - 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. suomec/ovalidator

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

suomec/ovalidator
=================

Objects validator and properties mapper for PHP

v1.0.3(2y ago)08MITPHPPHP &gt;=8.1

Since Aug 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/suomec/ovalidator)[ Packagist](https://packagist.org/packages/suomec/ovalidator)[ RSS](/packages/suomec-ovalidator/feed)WikiDiscussions main Synced yesterday

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

PHP object mapper and schema validator (PHP version &gt;= 8.1)
==============================================================

[](#php-object-mapper-and-schema-validator-php-version--81)

This package created for mapping user input to pre-defined objects with validation schema (custom rules).

Usually you have user input as array and need to map/validate it to your value-objects. This package can help you.

First, you need a Form - class, that contains user raw data. It's /src/Form.php class.

```
$form = (new Form())->fromArray([
    'field_1' => 'any value',
    'field_2' => 15,
]);
```

Second, you need an object, with internal properties. It's just an instance of *your* class.

```
class Input
{
    public int $field_2;
}

$input = new Input();
```

Third, you need a set of rules to map input to that class. It's a Config. Rules are set of -&gt;add() methods

```
$config = (new Config())
    ->add('field_2', 'Some description', State::Required, [
        new VInteger(),
        new VMin(10),
        new VMax(20),
    ])
;
```

And the last - some code for validation and map

```
$result = (new Mapper($form, $config))->toObject($input, new ReflectionSetter());
```

If you have an input: `['field_2' => 15]` it's correct and `$input->field_2` will have a value of `15`. But for input `['field_2' => 999]` `$result` variable will contain a list of errors (VMax check fails, because 999 &gt; 20).

### Installation

[](#installation)

Run: `composer require suomec/ovalidator`

### Validators

[](#validators)

Builtin validator are described in [validators.md](validators.md) file. You can create own validator which should implement `Validator` interface.

### Setters

[](#setters)

Setters are special objects which map validated input to your object. There are two default setters - **Direct** and **Reflection**-based. First setter just apply input to object via `$object->$property` without extended checks. Second setter checks types of properties via reflection and supported interfaces if property is another object.

### Localization

[](#localization)

Localization files are located in /etc/ folder. There is a class for quick validation run: OValidator::validateAndSet() It creates localization object from default file *loc-en.php*. You can pass path to your own file if needed.

### Examples

[](#examples)

You can find **more examples** at the /examples/ dir. There are a lot of different cases where that mapper and validator can be used. Fell free to create issue for any questions or improvements.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~97 days

Total

4

Last Release

773d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/110372406?v=4)[Suomi Person](/maintainers/suomec)[@suomec](https://github.com/suomec)

---

Top Contributors

[![suomec](https://avatars.githubusercontent.com/u/110372406?v=4)](https://github.com/suomec "suomec (1 commits)")

---

Tags

php8validation

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/suomec-ovalidator/health.svg)

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

###  Alternatives

[marcosh/php-validation-dsl

A DSL for validating data in a functional fashion

483.9k](/packages/marcosh-php-validation-dsl)

PHPackages © 2026

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