atelierspierrot / validators
此包已被弃用且不再维护。未建议替代包。
符合RFC的PHP验证器
v1.1.0
2015-03-04 23:55 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpmd/phpmd: 1.4.*
- phpunit/phpunit: 3.7.*
- sami/sami: dev-master
This package is not auto-updated.
Last update: 2024-03-02 11:44:50 UTC
README
一个PHP验证器包,用于测试RFC的兼容性。
用法
所有验证器都必须实现 \Validator\ValidatorInterface
接口,该接口定义了两个方法
validate( thing )
必须返回一个布尔值,表示thing
是否通过验证测试sanitize( thing )
必须返回thing
的清理版本,该版本必须通过验证测试
\Validator\EmailValidator
的示例用法(每个验证器使用相同的过程)
$thing = 'my.address@email.com'; $v = new \Validator\EmailValidator(); if ($v->validate($thing)) { // $thing is OK ... } else { // $thing is KO ... $new_thing = $v->sanitize($thing); // $new_thing must be OK ... }
安装
有关如何安装此包及其命名空间的完整信息,请参阅我们的 用法 文档。
如果您是 Composer 用户,只需将包添加到项目 composer.json
清单文件的要求中
"atelierspierrot/validators": "@stable"
您可以使用特定版本或主要版本的最新版本,使用适当的 版本约束。
作者 & 许可证
验证器
版权所有 (c) 2013-2016 Pierre Cassat 和贡献者
Apache 2.0 许可证下发布。
Les Ateliers Pierrot - 巴黎,法国
http://www.ateliers-pierrot.fr/ - contact@ateliers-pierrot.fr