mittwald/psr7-validation
Composer 安装命令:
composer require mittwald/psr7-validation
包简介
PSR-7 middleware for JSON schema validation
README 文档
README
Synposis
This package contains a PSR-7 middleware for validating HTTP requests, especially using JSON schema validation.
Warning: This package is still under development; its API can change at any time without notice. Use at own risk.
License
This package is MIT-licensed.
Examples
Validating request bodies using a JSON schema (using the Slim framework):
$app->post('/customers', $handler) ->add(new ValidationMiddleware( Factory::buildJsonValidatorFromUri('path/to/json-schema.json') ));
Validating request bodies using a Swagger specification file:
$app->post('/customers', $handler) ->add(new ValidationMiddleware( Factory::buildJsonValidatorFromSwaggerDefinition('path/to/swagger.json', 'MyType') ));
Validating request bodies using a custom validator (using PHP 7's anonymous classes, for no other reason because I can):
$app->post('/customers', $handler) ->add(new ValidationMiddleware( new class implements ValidatorInterface { public function validateJson($jsonDocument, ValidationResult $result) { $result->addErrorForProperty('customernumber', 'Foo'); } } ));
Combining multiple validators:
$app->post('/customers', $handler) ->add(new ValidationMiddleware( new CombinedValidator( Factory::buildJsonValidatorFromUri('path/to/schema.json'), new MyVerySpecialCustomValidator() ) ));
mittwald/psr7-validation 适用场景与选型建议
mittwald/psr7-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.03k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2017 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mittwald/psr7-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mittwald/psr7-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-30