PHP code example of grizz-it / json-schema

1. Go to this page and download the library: Download grizz-it/json-schema library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grizz-it / json-schema example snippets




use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

$factory = new SchemaValidatorFactory();



use GrizzIt\Validator\Common\ValidatorInterface;

/** @var ValidatorInterface $validator */
$validator($myData); // returns true or false.



use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

/** @var object|bool $schema */
/** @var SchemaValidatorFactory $factory */
$factory->create($schema);



use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

/** @var object|bool $schema */
/** @var SchemaValidatorFactory $factory */
$factory->createVerifiedValidator($schema);



use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

/** @var SchemaValidatorFactory $factory */
$factory->createFromLocalFile('path/to/my/schema.json');



use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

/** @var SchemaValidatorFactory $factory */
$factory->createFromRemoteFile('http://json-schema.org/draft-07/schema#');



use GrizzIt\JsonSchema\Factory\SchemaValidatorFactory;

/** @var SchemaValidatorFactory $factory */
$factory->createFromString(
    '{"$ref": "http://json-schema.org/draft-07/schema#"}'
);