PHPackages                             dentelis/php-json-structure-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. [Testing &amp; Quality](/categories/testing)
4. /
5. dentelis/php-json-structure-validator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

dentelis/php-json-structure-validator
=====================================

Json data structure validation framework

2.0.0(2y ago)19103MITPHPPHP ~8.2

Since Feb 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dentelis/php-json-structure-validator)[ Packagist](https://packagist.org/packages/dentelis/php-json-structure-validator)[ RSS](/packages/dentelis-php-json-structure-validator/feed)WikiDiscussions master Synced 1mo ago

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

dentelis/php-json-structure-validator
=====================================

[](#dentelisphp-json-structure-validator)

Validator is a lightweight PHP library for validating the structure of data retrieved from an external json API.

The library was originally created for use in acceptance api tests, but can be used anywhere else as well.

Specific
--------

[](#specific)

The library was made to test json compatible data structures. Array key validation is not supported.

Installation
------------

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install.

```
composer require dentelis/php-json-structure-validator
```

Usage
-----

[](#usage)

You can use library with(or without) any testing framework you want.

See [dentelis/phpunit-json-assert](https://github.com/dentelis/phpunit-json-assert) for PhpUnit support.

```
//object example
$user = (new ObjectType())
    ->addProperty('name', (new StringType())->assertNotEmpty())
    ->addProperty('email', (new StringType())->assertEmail());

$data = json_decode('{"name":"user", "email":"user@example.com"}');
try {
    $user->validate($data);
} catch (ValidationException $e) {
    //do smth

}

//array of objects
$users = (new ArrayType())
    ->assertNotEmpty()
    ->assertType($user);

$data = json_decode('[{"name":"user", "email":"user@example.com"},{"name":"user", "email":"user@example.com"}]');
try {
    $users->validate($data);
} catch (ValidationException $e) {
    //do smth

}
```

See [examples](https://github.com/dentelis/validator/tree/master/examples) directory for full example.

Todo
----

[](#todo)

- more examples
- proper path in exceptions
- do not fail on first exception
- comments translate to english
- create TypeInterface from Classname (what to do with arrays)

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

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

832d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cb013397f7fab594213b994307d388cc36c8eb9125038f5bce554bd125d0fb18?d=identicon)[dentelis](/maintainers/dentelis)

---

Top Contributors

[![dentelis](https://avatars.githubusercontent.com/u/5281445?v=4)](https://github.com/dentelis "dentelis (74 commits)")

---

Tags

assertassertionsjsonphp8structuretestingvalidatevalidation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dentelis-php-json-structure-validator/health.svg)

```
[![Health](https://phpackages.com/badges/dentelis-php-json-structure-validator/health.svg)](https://phpackages.com/packages/dentelis-php-json-structure-validator)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)

PHPackages © 2026

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