PHPackages                             atk4/validate - 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. [Framework](/categories/framework)
4. /
5. atk4/validate

ActiveLibrary[Framework](/categories/framework)

atk4/validate
=============

Agile Data - Validator add-on

5.0.0(2y ago)48.2k2MITPHPPHP &gt;=7.4 &lt;8.4CI passing

Since Dec 15Pushed 1y ago8 watchersCompare

[ Source](https://github.com/atk4/validate)[ Packagist](https://packagist.org/packages/atk4/validate)[ Docs](https://github.com/atk4/validate)[ RSS](/packages/atk4-validate/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (8)Dependencies (10)Versions (12)Used By (0)

Validator for Agile Data
========================

[](#validator-for-agile-data)

This is validator add-on for Agile Data ().

It uses  under the hood.

[![Code Climate](https://camo.githubusercontent.com/77aa7dd1bebe02a506791bcb7a2feb8afd573ca14e2006850cce60da162f1fc7/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f61746b342f76616c69646174652f6261646765732f6770612e737667)](https://codeclimate.com/github/atk4/validate)[![StyleCI](https://camo.githubusercontent.com/9a9448a99235888f546b684edc15185ac67b331d398efdfeaa8e8bf14806d546/68747470733a2f2f7374796c6563692e696f2f7265706f732f3136313639353332302f736869656c64)](https://styleci.io/repos/161695320)[![CodeCov](https://camo.githubusercontent.com/c7769b05afe7c67c50b872ea8f331bd725d16596069c3e61477dce211d628ca6/68747470733a2f2f636f6465636f762e696f2f67682f61746b342f76616c69646174652f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/atk4/validate)[![Test Coverage](https://camo.githubusercontent.com/417efbea8d62d5accdc9bf3340ff52592d141b1614a2c26f11c424ed72977f94/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f61746b342f76616c69646174652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/atk4/validate/coverage)[![Issue Count](https://camo.githubusercontent.com/ea5d6eb11a932b29f5ecec6f8f91b2a2970e5d7d8c71f1eaaf93b03df1a9c425/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f61746b342f76616c69646174652f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/atk4/validate)

[![License](https://camo.githubusercontent.com/57b5b766915b683e188e308ec1f797bf73a85ef848eb5d8078323d13feba60d4/68747470733a2f2f706f7365722e707567782e6f72672f61746b342f76616c69646174652f6c6963656e7365)](https://packagist.org/packages/atk4/validate)[![GitHub release](https://camo.githubusercontent.com/3be57e643d12a52af4f355eb64e06484713be45bdddea8b529ef3ae45b990dbc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f61746b342f76616c69646174652e7376673f6d61784167653d32353932303030)](CHANGELOG.md)

Usage
=====

[](#usage)

```
// add model fields
$model->addField('name');
$model->addField('age', ['type' => 'number']);
$model->addField('type', ['required' => true, 'enum' => ['dog', 'ball']]);
$model->addField('tail_length', ['type' => 'number']);

// add validator to your model
// also will register itself as $model->validator property
$v = new \Atk4\Validate\Validator($model);

// set simple validation rule for one field
// ->rule($field, $rules)
$v->rule('name', [ 'required', ['lengthMin', 3] ]);

// set multiple validation rules in one shot
// ->rules($array_of_rules) // [field=>rules]
$v->rules([
    'name' => ['required', ['lengthMin',3]],
    'age' => ['integer', ['min',0], ['max',99]],
    'tail_length' => ['integer', ['min',0]],
]);

// set validation rules based on value of another field
// if type=dog, then sets fields age and tail_length as required
// ->if($condition, $then_array_of_rules, $else_array_of_rules)
$v->if(['type'=>'dog'], [
    'age' => ['required'],
    'tail_length' => ['required'],
], [
    'tail_length' => [ ['equals',''] ], // balls don't have tail
]);

// you can also pass multiple conditions which will be treated as AND conditions
$v->if(['type'=>'dog', 'age'=>50], $rules_if_true, $rules_if_false);

// you can also set custom error message like this:
$v->rule('age', [ ['min', 3, 'message'=>'Common! {field} to small'] ]);
// and you will get this "Common! Age to small"
```

You can also pass callback instead of array of rules. Callback receives these parameters $field, $value, $args, $data and should return true/false.

See `/tests` folder for more examples.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.3% 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 ~277 days

Recently: every ~379 days

Total

8

Last Release

766d ago

Major Versions

0.5.0 → 4.0.02024-04-07

4.0.0 → 5.0.02024-04-08

PHP version history (5 changes)0.1PHP &gt;=7.0.0

0.4PHP &gt;=7.2.0

0.5.0PHP &gt;=7.3.0

4.0.0PHP &gt;=7.4 &lt;8.3

5.0.0PHP &gt;=7.4 &lt;8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/426ad318d07e7685454f7e449a9d0c9f005b83aef0777558d97d854ff9c28a5a?d=identicon)[romaninsh](/maintainers/romaninsh)

---

Top Contributors

[![DarkSide666](https://avatars.githubusercontent.com/u/1969119?v=4)](https://github.com/DarkSide666 "DarkSide666 (55 commits)")[![abbadon1334](https://avatars.githubusercontent.com/u/5801824?v=4)](https://github.com/abbadon1334 "abbadon1334 (4 commits)")[![romaninsh](https://avatars.githubusercontent.com/u/453929?v=4)](https://github.com/romaninsh "romaninsh (4 commits)")

---

Tags

agileatk4phpvalidateframeworkvalidatorormmysqlpostgresqlsqlquerybuildernosqlvalidatemongodbactive-record

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/atk4-validate/health.svg)

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

###  Alternatives

[atk4/data

Agile Data - Database access abstraction framework

2811.7M37](/packages/atk4-data)[nilportugues/sql-query-builder

An elegant lightweight and efficient SQL QueryInterface BuilderInterface supporting bindings and complicated query generation.

425239.4k6](/packages/nilportugues-sql-query-builder)

PHPackages © 2026

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