Download the PHP package teamones/think-validate without Composer
On this page you can find all versions of the php package teamones/think-validate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teamones/think-validate
More information about teamones/think-validate
Files in teamones/think-validate
Package think-validate
Short Description Teamones think-validate fork with strict integer validation and PHP 8.5 regression coverage
License Apache-2.0
Informations about the package think-validate
Teamones think-validate
Forked from top-think/think-validate v3.0.7. Existing think\Validate namespace and APIs are unchanged.
Install: composer require teamones/think-validate:^3.0
The integer / int rule validates the original input with FILTER_VALIDATE_INT, rather than casting first. Fractions such as 1.5 / "1.5", booleans, arrays, objects, overflow and non-decimal numeric strings are rejected. Canonical signed decimal integers, zero, numeric integer strings and integral floats (for example 1.0) remain valid. Leading-zero strings such as "01" and scientific notation strings such as "1e3" are rejected, matching the PHP integer filter used before upstream v3.0.7. Optional empty-value behavior is unchanged.
Run composer test under PHP 8.5 with E_ALL; tests fail on any warning or deprecation.
Original Apache-2.0 license and upstream source notices are preserved.
think-validate
基于PHP8.0+ 的Validate实现
主要特性
- 基于PHP8和强类型实现
- 内置丰富的验证规则
- 支持验证器类、数组和链式方法定义验证规则
- 支持验证场景和验证分组
- 支持独立数据验证
- 支持枚举验证
- 支持批量验证
- 支持抛出异常
安装
composer require topthink/think-validate
用法
use think\facade\Validate;
$validate = Validate::rule([
'name' => 'require|max:25',
'email' => 'email'
]);
$data = [
'name' => 'thinkphp',
'email' => '[email protected]'
];
if (!$validate->check($data)) {
var_dump($validate->getError());
}
支持创建验证器进行数据验证
验证器调用代码如下:
$data = [
'name' => 'thinkphp',
'email' => '[email protected]',
];
$validate = new \app\index\validate\User;
if (!$validate->check($data)) {
var_dump($validate->getError());
}
文档
详细使用请参考 ThinkValidate开发指南