src/File/Json.php
protected function validateSchema()
    {
        $schemaPath = $this->getOption('schemaPath');

        if ($schemaPath === null) {
            return;
        }

        $schemaData = json_decode(file_get_contents($schemaPath));

        if (!class_exists('\\JsonSchema\\Validator')) {
            throw new \RuntimeException(
                'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-'
            );
        }

        $validator = new \JsonSchema\Validator();
        $validator->check($this->getContents(), $schemaData);

        if (!$validator->isValid()) {
            $errors = [];

            foreach ((array) $validator->getErrors() as $error) {
                $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
            }

            throw DecodeException::create($this->getPath(), ['errors' => $errors]);
        }
    }
protected function validateSchema()
    {
        $schemaPath = $this->getOption('schemaPath');

        if ($schemaPath === null) {
            return;
        }

        $schemaData = json_decode(file_get_contents($schemaPath));

        if (!class_exists('\\JsonSchema\\Validator')) {
            throw new \RuntimeException(
                'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-'
            );
        }

        $validator = new \JsonSchema\Validator();
        $validator->check($this->getContents(), $schemaData);

        if (!$validator->isValid()) {
            $errors = [];

            foreach ((array) $validator->getErrors() as $error) {
                $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
            }

            throw DecodeException::create($this->getPath(), ['errors' => $errors]);
        }
    }
protected function validateSchema ( ) { $ schemaPath = $ this -> getOption ( 'schemaPath' ) ; if ( $ schemaPath === null ) { return ; } $ schemaData = json_decode ( file_get_contents ( $ schemaPath ) ) ; if ( ! class_exists ( '\\JsonSchema\\Validator' ) ) { throw new \ RuntimeException ( 'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-' ) ; } $ validator = new \ JsonSchema \ Validator ( ) ; $ validator -> check ( $ this -> getContents ( ) , $ schemaData ) ; if ( ! $ validator -> isValid ( ) ) { $ errors = [ ] ; foreach ( ( array ) $ validator -> getErrors ( ) as $ error ) { $ errors [ ] = ( $ error [ 'property' ] ? $ error [ 'property' ] . ' : ' : '' ) . $ error [ 'message' ] ; } throw DecodeException :: create ( $ this -> getPath ( ) , [ 'errors' => $ errors ] ) ; } }
Validates JSON schema.

@throws DecodeException

@return void
Validates JSON schema .