urbanminded / json-verifier
Lightweight JSON verifier
Installs: 71
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/urbanminded/json-verifier
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-10-25 22:55:44 UTC
README
use JSONVerifier\Verifier; $schema = [ // 'name' must be a string 'name' => 'string', // 'age' is an optional key. // if present it must be an integer. '?age' => 'int', // 'favouriteFood' is an optional key. // if present it must be a string or null. '?favouriteFood' => '?string', // 'pets' must be an array of objects matching the // prescribed shape. 'pets' => Verifier::arrayOf('string', [ 'name' => 'string', 'species' => 'string' ]) ]; $verifier = new Verifier(); $verifier->verifyObject($schema, [ 'name' => 'Jason', 'favouriteFood' => null, 'pets' => [ 'Dora', ['name' => 'Ruby', 'species' => 'cat'], ['name' => 'Byron', 'species' => 'cat'], ['name' => 'Mitzi', 'species' => 'cat'], ] ]);
Installation
composer require urbanminded/json-verifier