chubbyphp/chubbyphp-validation
最新稳定版本:4.0.0
Composer 安装命令:
composer require chubbyphp/chubbyphp-validation
包简介
Chubbyphp Validate
关键字:
README 文档
README
chubbyphp-validation
Description
A simple validation.
DEPRECATED: No personal interest anymore and based on stats nobody seems to use it. Feel free to create an issue if you disagree. Please take a look to chubbyphp-parsing its a different concept. But i believe parsing is the way to go instead of deserialze/validate.
Requirements
- php: ^8.1
- psr/log: ^2.0|^3.0
Suggest
- chubbyphp/chubbyphp-container: ^2.2
- pimple/pimple: ^3.5
- psr/container: ^2.0.2
Installation
Through Composer as chubbyphp/chubbyphp-validation.
composer require chubbyphp/chubbyphp-validation "^4.0"
Usage
Accessor
Constraint
- AllConstraint
- BlankConstraint
- CallbackConstraint
- ChoiceConstraint
- CoordinateArrayConstraint
- CoordinateConstraint
- CountConstraint
- DateTimeConstraint
- EmailConstraint
- FalseConstraint
- MapConstraint
- NotBlankConstraint
- NotNullConstraint
- NullConstraint
- NumericConstraint
- NumericRangeConstraint
- TrueConstraint
- TypeConstraint
- ValidConstraint
Doctrine
Symfony
Error
Mapping
- CallableValidationMappingProvider
- LazyValidationMappingProvider
- ValidationClassMapping
- ValidationClassMappingBuilder
- ValidationMappingProviderRegistry
- ValidationPropertyMapping
- ValidationPropertyMappingBuilder
ValidationMappingProvider
<?php namespace MyProject\Model; final class Model { /** * @var array<\DateTime> */ private $dates; }
<?php namespace MyProject\Mapping\Validation; use Chubbyphp\Validation\Constraint\AllConstraint; use Chubbyphp\Validation\Constraint\DateTimeConstraint; use Chubbyphp\Validation\Constraint\NotBlankConstraint; use Chubbyphp\Validation\Constraint\NotNullConstraint; use Chubbyphp\Validation\Mapping\ValidationClassMappingBuilder; use Chubbyphp\Validation\Mapping\ValidationClassMappingInterface; use Chubbyphp\Validation\Mapping\ValidationMappingProviderInterface; use Chubbyphp\Validation\Mapping\ValidationPropertyMappingBuilder; use Chubbyphp\Validation\Mapping\ValidationPropertyMappingInterface; use MyProject\Model\Model; final class ModelValidationMappingProvider implements ValidationMappingProviderInterface { /** * @return string */ public function getClass(): string { return Model::class; } /** * @param string $path * * @return ValidationClassMappingInterface */ public function getValidationClassMapping(string $path): ValidationClassMappingInterface { return ValidationClassMappingBuilder::create([])->getMapping(); } /** * @param string $path * @param string|null $type * * @return ValidationPropertyMappingInterface[] */ public function getValidationPropertyMappings(string $path, string $type = null): array { return [ ValidationPropertyMappingBuilder::create('dates', [ new AllConstraint([ new NotNullConstraint(), new NotBlankConstraint(), new DateTimeConstraint('d.m.Y'), ]), ])->getMapping(), ]; } }
ServiceFactory
chubbyphp-container
chubbyphp-laminas-config-factory
ServiceProvider
Validator
<?php namespace MyProject; use Chubbyphp\Validation\Mapping\ValidationMappingProviderRegistry; use Chubbyphp\Validation\ValidatorContextInterface; use Chubbyphp\Validation\Validator; use MyProject\Mapping\Validation\ModelValidationMappingProvider; use MyProject\Model\Model; $logger = ...; $validator = new Validator( new ValidationMappingProviderRegistry([ new ModelValidationMappingProvider() ]), $logger ); $model = new Model; /** @var ValidatorContextInterface $context */ $context = ...; $errors = $validator->validate( $model, $context );
Copyright
2024 Dominik Zogg
chubbyphp/chubbyphp-validation 适用场景与选型建议
chubbyphp/chubbyphp-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.66k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2016 年 10 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validation」 「slim」 「chubbyphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chubbyphp/chubbyphp-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chubbyphp/chubbyphp-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chubbyphp/chubbyphp-validation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Allows parsing data of various structures, meaning the population and validation of data into a defined structure. For example, converting an API request into a Data Transfer Object (DTO).
Secure session middleware for Slim 3 framework
Chubbyphp database service provider
Chubbyphp Config
Chubbyphp Api Http
A request handler adapter for swoole, using PSR-7, PSR-15 and PSR-17.
统计信息
- 总下载量: 17.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 15
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-01