{"id":18838880,"url":"https://github.com/grizz-it/json-schema","last_synced_at":"2026-05-19T10:34:27.581Z","repository":{"id":62512767,"uuid":"341907404","full_name":"grizz-it/json-schema","owner":"grizz-it","description":"JSON schema validator.","archived":false,"fork":false,"pushed_at":"2021-02-24T13:23:01.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T07:04:39.424Z","etag":null,"topics":["json-schema","php","validation","validator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grizz-it.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-24T13:20:52.000Z","updated_at":"2021-04-03T14:56:59.000Z","dependencies_parsed_at":"2022-11-02T13:02:16.303Z","dependency_job_id":null,"html_url":"https://github.com/grizz-it/json-schema","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/grizz-it/json-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fjson-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fjson-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fjson-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fjson-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grizz-it","download_url":"https://codeload.github.com/grizz-it/json-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grizz-it%2Fjson-schema/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264222197,"owners_count":23575196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema","php","validation","validator"],"created_at":"2024-11-08T02:41:08.892Z","updated_at":"2026-05-19T10:34:27.550Z","avatar_url":"https://github.com/grizz-it.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/grizz-it/json-schema.svg?branch=master)](https://travis-ci.com/grizz-it/json-schema)\n\n# GrizzIT JSON Schema\n\nThis package contains a [JSON schema](https://json-schema.org/) validator\nlibrary for PHP. It support Draft 07 and 06.\n\nTo get a grip on JSON schema's, what they are and how they work, please see the\nmanual of [json-schema-org](https://json-schema.org/learn/).\n\nThe package generates a reusable validation object, which can be used to verify\ndata against.\n\n## Installation\n\nTo install the package run the following command:\n\n```\ncomposer require grizz-it/json-schema\n```\n\n## Usage\n\nBefore a validation object can be created, the factory for the validators needs\nto be instantiated. This can be done by using the following snippet:\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n$factory = new SchemaValidatorFactory();\n```\n\nAll of the below described method of generating a validation object will result\nin a [ValidatorInterface](https://github.com/grizz-it/validator/blob/master/src/Common/ValidatorInterface.php).\nTo verify data against this object, simply pass the data to the `__invoke`\nmethod, like so:\n```php\n\u003c?php\n\nuse GrizzIt\\Validator\\Common\\ValidatorInterface;\n\n/** @var ValidatorInterface $validator */\n$validator($myData); // returns true or false.\n```\n\nAfter the factory is created there are 4 options to create the validation object.\n\n### Object injection\n\nIf an object is already created by a (for example) a previous call to\n`json_decode` (second parameter must be either null or false, to get an object).\n\nThe validation object can be created by calling the `create` method on the\npreviously instantiated `SchemaValidatorFactory`.\n\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n/** @var object|bool $schema */\n/** @var SchemaValidatorFactory $factory */\n$factory-\u003ecreate($schema);\n```\n\nIt is also possible to create a verified validation object.\nThis is possible when the `$schema` property is set on the\nprovided schema. The schema will then be validated against\nthe schema which is defined on the property. This can be\ndone with the following snippet:\n\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n/** @var object|bool $schema */\n/** @var SchemaValidatorFactory $factory */\n$factory-\u003ecreateVerifiedValidator($schema);\n```\n\n### Local file\n\nTo create a validator object from a local schema file, it is also possible to\nreference this file location to a method and let this method load it. This\ncan be done with the following snippet:\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n/** @var SchemaValidatorFactory $factory */\n$factory-\u003ecreateFromLocalFile('path/to/my/schema.json');\n```\n\n### Remote file\n\nA schema can also be loaded from a remote location, for example:\n[http://json-schema.org/draft-07/schema#](http://json-schema.org/draft-07/schema#).\nTo load a schema from a remote location, use the following method:\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n/** @var SchemaValidatorFactory $factory */\n$factory-\u003ecreateFromRemoteFile('http://json-schema.org/draft-07/schema#');\n```\n\n### From string\n\nIf a validation object needs to be created from a JSON string, use the method\n`createFromString`.\n\n```php\n\u003c?php\n\nuse GrizzIt\\JsonSchema\\Factory\\SchemaValidatorFactory;\n\n/** @var SchemaValidatorFactory $factory */\n$factory-\u003ecreateFromString(\n    '{\"$ref\": \"http://json-schema.org/draft-07/schema#\"}'\n);\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## MIT License\n\nCopyright (c) GrizzIT\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrizz-it%2Fjson-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrizz-it%2Fjson-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrizz-it%2Fjson-schema/lists"}