{"id":26246377,"url":"https://github.com/mittwald/php-psr7-validation","last_synced_at":"2025-06-30T10:36:20.718Z","repository":{"id":57017754,"uuid":"51595293","full_name":"mittwald/php-psr7-validation","owner":"mittwald","description":"PSR-7 middlewares for JSON schema validation","archived":false,"fork":false,"pushed_at":"2018-04-16T07:55:25.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-24T20:41:04.026Z","etag":null,"topics":["json-schema-validator","middleware","php","php-library","psr","psr-7"],"latest_commit_sha":null,"homepage":null,"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/mittwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T15:01:40.000Z","updated_at":"2018-09-12T02:30:42.000Z","dependencies_parsed_at":"2022-08-22T12:00:27.981Z","dependency_job_id":null,"html_url":"https://github.com/mittwald/php-psr7-validation","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mittwald/php-psr7-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fphp-psr7-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fphp-psr7-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fphp-psr7-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fphp-psr7-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mittwald","download_url":"https://codeload.github.com/mittwald/php-psr7-validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittwald%2Fphp-psr7-validation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262412156,"owners_count":23306869,"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-validator","middleware","php","php-library","psr","psr-7"],"created_at":"2025-03-13T13:18:20.837Z","updated_at":"2025-06-30T10:36:20.678Z","avatar_url":"https://github.com/mittwald.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSR-7 validation middlewares\n\n[![Build Status](https://travis-ci.org/mittwald/php-psr7-validation.svg?branch=master)](https://travis-ci.org/mittwald/php-psr7-validation)\n\n## Synposis\n\nThis package contains a [PSR-7][psr7] middleware for validating HTTP requests,\nespecially using JSON schema validation.\n\n**Warning**: This package is still under development; its API can change at any time without notice. Use at own risk.\n\n## License\n\nThis package is [MIT-licensed](LICENSE.txt).\n\n## Examples\n\nValidating request bodies using a JSON schema (using the [Slim framework][slim]):\n\n```php\n$app-\u003epost('/customers', $handler)\n    -\u003eadd(new ValidationMiddleware(\n        Factory::buildJsonValidatorFromUri('path/to/json-schema.json')\n    ));\n```\n\nValidating request bodies using a [Swagger specification file][swag]:\n\n```php\n$app-\u003epost('/customers', $handler)\n    -\u003eadd(new ValidationMiddleware(\n        Factory::buildJsonValidatorFromSwaggerDefinition('path/to/swagger.json', 'MyType')\n    ));\n```\n\nValidating request bodies using a custom validator (using PHP 7's anonymous classes, for no other reason because I can):\n\n```php\n$app-\u003epost('/customers', $handler)\n    -\u003eadd(new ValidationMiddleware(\n        new class implements ValidatorInterface {\n            public function validateJson($jsonDocument, ValidationResult $result) {\n                $result-\u003eaddErrorForProperty('customernumber', 'Foo');\n            }\n        }\n    ));\n```\n\nCombining multiple validators:\n\n```php\n$app-\u003epost('/customers', $handler)\n    -\u003eadd(new ValidationMiddleware(\n        new CombinedValidator(\n            Factory::buildJsonValidatorFromUri('path/to/schema.json'),\n            new MyVerySpecialCustomValidator()\n        )\n    ));\n```\n\n\n\n[slim]: http://www.slimframework.com/\n[swag]: http://swagger.io/specification/\n[psr7]: http://www.php-fig.org/psr/psr-7/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittwald%2Fphp-psr7-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmittwald%2Fphp-psr7-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittwald%2Fphp-psr7-validation/lists"}