PHPackages                             graze/config-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. graze/config-validation

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

graze/config-validation
=======================

validate and populate arrays and objects

1.0.0(1mo ago)19711MITPHPPHP ^7.4 | ^8.0CI passing

Since Oct 2Pushed 1mo ago10 watchersCompare

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

READMEChangelog (3)Dependencies (8)Versions (7)Used By (1)

config-validation
=================

[](#config-validation)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0992064bdbabd41bf80fa199fd7e68c8a98bfac0787a1489c729b46300bfb526/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a652f636f6e6669672d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/config-validation)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![CI](https://github.com/graze/config-validation/actions/workflows/ci.yml/badge.svg)](https://github.com/graze/config-validation/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/ed37c8dcdb6eff98266efd835d4c5d34180e5ed8585132d709bf3d26785d67df/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6772617a652f636f6e6669672d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/config-validation/code-structure)[![Quality Score](https://camo.githubusercontent.com/7f11cf195b3f95a756a03eeabd4b89fc80c65eb9cce6f4fe5f2966c8056f5454/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6772617a652f636f6e6669672d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/graze/config-validation)[![Total Downloads](https://camo.githubusercontent.com/67d24aa9cc1e8985ff19c326325620da883b1ebf7191c853903a2373a27b0243/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617a652f636f6e6669672d76616c69646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graze/config-validation)

Config Validation checks an input against a code defined schema for validation using short notation syntax.

It then populates optional fields with default data.

Install
-------

[](#install)

Via Composer

```
composer require graze/config-validation
```

Usage
-----

[](#usage)

### Long path definition

[](#long-path-definition)

```
use Respect\Validation\Validator as v;

$validator = (new ArrayValidator())
    ->required('key', v::stringType())
    ->optional('parent.child', v::intVal(), 1)
    ->optional('parent.second', v::stringType()->date());
```

### Using children

[](#using-children)

```
$validator = Validator::arr()
    ->required('key', v::stringType())
    ->addChild('parent', Validator::arr()
        ->optional('child', v::intVal(), 1)
        ->optional('second', v::stringType()->date()
    );
```

### Validating with your validator

[](#validating-with-your-validator)

```
function thing (array $input) {
    return $validator->validate($input);
}

thing(['key' => 'value'])
// ['key' => 'value', 'parent' => ['child' => 1, 'second' => null]]
thing();
// throws new ConfigValidationFailed
thing(['key' => 'input', ['parent' => ['child' => 2]])
// ['key' => 'input', ['parent' => ['child' => 2, 'second' => null]]
thing(['key' => 'input', ['parent' => ['second' => '111']])
// throws new ConfigValidationFailed('expected data for parent.second')
thing(['key' => 'input', ['parent' => ['second' =>
```

### Validating array items with variable keys

[](#validating-array-items-with-variable-keys)

```
$childValidator = Validate::object()
    ->required('key->item', v::intVal()->min(2)->max(4))
    ->optional('key->second', v::stringType(), 'name');
$validator = Validate::object()
    ->required('items', v::arrayVal()->each(
        $childValidator->getValidator()
    ));

function thing ($input) {
    return $validator->validate($input);
}

thing((object) ['items' => [
    (object) ['key' => 3],
    ]]);
// (object) ['items' => [
//     (object) ['key' => (object) ['item' => 3, 'second' => 'name']]
// ]]
```

Testing
-------

[](#testing)

```
make build test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Harry Bragg](https://github.com/h-bragg)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance93

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

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

Total

4

Last Release

34d ago

Major Versions

0.2 → 1.0.02026-05-28

PHP version history (2 changes)0.1PHP ^5.6 | ^7.0

1.0.0PHP ^7.4 | ^8.0

### Community

Maintainers

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

---

Top Contributors

[![rick-lam](https://avatars.githubusercontent.com/u/114425681?v=4)](https://github.com/rick-lam "rick-lam (4 commits)")

---

Tags

grazeconfig-validation

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/graze-config-validation/health.svg)

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

###  Alternatives

[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65399.7k9](/packages/awurth-slim-validation)[progsmile/request-validator

Simple PHP Request Validator

37114.5k1](/packages/progsmile-request-validator)[resultsystems/validation

Inspired 'KennedyTedesco Validation' - The power of 'Respect Validation' on Laravel.

2832.8k4](/packages/resultsystems-validation)

PHPackages © 2026

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