PHP code example of schematicon / validator

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

    

schematicon / validator example snippets


$normalizer = new Schematicon\Validator\Normalizer();
$schema = Neon\Neon::decode(file_get_contents('./my_family.neon'));
$schema = $normalizer->normalize($schema);
$validator = new Schematicon\Validator\Validator($schema);

$result = $validator->validate([
	'name' => 'jon',
	'surname' => 'snow',
	'sex' => 'male',
	'age' => 18,
	'height' => 180.00,
	'siblings' => ['Arya'],
]);

$result->isValid(); // true
$result->getErrors(); // []