PHP code example of onlinesid / json-schema-provider

1. Go to this page and download the library: Download onlinesid/json-schema-provider 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/ */

    

onlinesid / json-schema-provider example snippets


$app->register(new OnlineSid\Silex\Provider\JsonSchema\ServiceProvider(), array(
    'json-schema.options' => array(
        'json_schema_dir' => __DIR__.'/public/json-schema/',
        'json_message_dir' => __DIR__.'/public/json-message/',
        'default_json_message' => 'default.json',
    ),
));

$validator = $this->app['json-schema-validator'];
$validation_result = $validator->validate(array(
    'request' => $this->request->get('booking'), // array to validate
    'json_schema' => 'booking.json', // under json_schema_dir
    'json_message' => 'booking.json', // under json_message_dir
));

// check $validation_result->isValid() to see if validation pass or fail