PHP code example of zweifisch / jsonschema

1. Go to this page and download the library: Download zweifisch/jsonschema 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/ */

    

zweifisch / jsonschema example snippets


$validator = new \jsonschema\Validator;

if($errors = $validator->validate($input, $schema))
{
	foreach($errors as $error)
	{
		list($constrain, $detail, $key) = $error;
	}
}
else
{
	// $input is valid
}

try
{
	$errors = $validator->validate($input, $schema, true);
}
catch(Exception $e)
{
	// $schema is invalid
}