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

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

b-tokman/validation
===================

Simple standalone PHP validation trait. That can be user in any object

1.0.0(6y ago)41MITPHPPHP ^7.2.5CI failing

Since Mar 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/bTokman/validation)[ Packagist](https://packagist.org/packages/b-tokman/validation)[ RSS](/packages/b-tokman-validation/feed)WikiDiscussions master Synced 5d ago

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

 PHP VALIDATION TRAIT
=====================

[](#--php-validation-trait)

 [ ![Programming language](https://camo.githubusercontent.com/d062e6e37140edb72513c33f232a718d3a0da5db94832c5fd814383e8a1b1156/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c616e672f622d746f6b6d616e2f76616c69646174696f6e) ](https://packagist.org/packages/b-tokman/validation) [ ![Scrutinizer code quality](https://camo.githubusercontent.com/990c941ac243562e6b3999016380948da118a04e08fd590422778f9626d4ccb3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62546f6b6d616e2f76616c69646174696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572) ](https://scrutinizer-ci.com/g/bTokman/validation/?branch=master) [ ![Travis build](https://camo.githubusercontent.com/5a9e06f3f19da629b99d2175ef89a899d8031856fb759429af643324c2238d15/68747470733a2f2f62616467656e2e6e65742f7472617669732f62546f6b6d616e2f76616c69646174696f6e) ](https://travis-ci.org/github/bTokman/validation)

This is a simple PHP standalone trait, that can be used to validate properties in any object. The validation process based on the [Symfony Validation Component](https://symfony.com/doc/current/components/validator.html)

🚀 Installation
==============

[](#rocket--installation)

This library requeired [PHP](https://www.php.net) version `7.2` or highter. And [composer](https://getcomposer.org/) - package manger for PHP.

```
  $ composer require b-tokman/validation
```

💡 Usage
=======

[](#bulb-usage)

After the installation you'll be able to use the `bTokman\validation\ValidationTrait` trait in your app.

**You cannot override a trait's property in the class where the trait is used.**However, you can override a trait's property in a class that extends the class where the trait is used:

- Start using trait in your base class
- Declare validation rules in your extended class. [List of availible Rules](https://symfony.com/doc/current/validation.html#constraints)
- On a new instance of your class just call method `validate`.

```
class BaseObject
{
    use bTokman\validation\ValidationTrait;
}

......

class ValidationObject extends BaseObject
{
    public $validationRules = [
        'password' => [NotBlank::class, [Length::class, ['min' => 8]]],
    ];

    public $password;
}

......

$object = new ValidationObject();

$result = $object->validate();
```

Or you can override a trait's property in a class constructor:

```
class ValidationObject
{
    use bTokman\validation\ValidationTrait;

    public function __construct()
    {
        $this->validationRules = [
            'password' => [NotBlank::class, [Length::class, ['min' => 8]]],
        ];
    }

    public $password;
}

$object = new ValidationObject();

$result = $object->validate();
```

**The validation result is**

- `array` of errors `[[fieldName] => [errorMessage1, errorMessag2, ...]` .
- `null` if the validation was passed.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

2248d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23096113?v=4)[Bohdan](/maintainers/bTokman)[@bTokman](https://github.com/bTokman)

---

Top Contributors

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

---

Tags

php-traitsphp-validationphp-validatorsymfony-validatorphpvalidationtraitstandaloneSymfony Validation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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