src/Common/Json.php
public static function validate($data, string $fileSchema): bool
    {
        /**
         * Throw an \Exception in case if there's no file or is unreadable
         */
        if (!file_exists($fileSchema) || !is_readable($fileSchema)) {
            throw new \Exception("The file {$fileSchema} not exists or is not readable.");
        }

        $jsonSchema = self::decode(file_get_contents($fileSchema));

        self::getValidator()->validate($data, $jsonSchema);

        return self::getValidator()->isValid();
    }
public static function validate($data, string $fileSchema): bool
    {
        /**
         * Throw an \Exception in case if there's no file or is unreadable
         */
        if (!file_exists($fileSchema) || !is_readable($fileSchema)) {
            throw new \Exception("The file {$fileSchema} not exists or is not readable.");
        }

        $jsonSchema = self::decode(file_get_contents($fileSchema));

        self::getValidator()->validate($data, $jsonSchema);

        return self::getValidator()->isValid();
    }
public static function validate ( $ data , string $ fileSchema ) : bool { /**
         * Throw an \Exception in case if there's no file or is unreadable
         */ if ( ! file_exists ( $ fileSchema ) || ! is_readable ( $ fileSchema ) ) { throw new \ Exception ( "The file {$fileSchema} not exists or is not readable." ) ; } $ jsonSchema = self :: decode ( file_get_contents ( $ fileSchema ) ) ; self :: getValidator ( ) -> validate ( $ data , $ jsonSchema ) ; return self :: getValidator ( ) -> isValid ( ) ; }
Check if the data is according JSON Schema

@author Edson B S Monteiro <bruno.monteirodg@gmail.com>
@since 1.0
@param \stdClass|array $data
@param string $fileSchema
@return bool
@throws \Exception
Check if the data is according JSON Schema