stantabcorp/validator
最新稳定版本:1.3.0
Composer 安装命令:
composer require stantabcorp/validator
包简介
A PHP Validation library
README 文档
README
A simple PHP validation library
Installation
composer require stantabcorp/validator
Using the library
$validator = new \Stantabcorp\Validator\Validator(["array" => ["to" => "validate"]]); // Init the library providing an array to validate. $validator->required("array.to"); // Test if the key `to` in the array `array` is present. $validator->array("array"); // Test if the key `array` is an array. $validator->isValid(); // Return a boolean is the array is valid or not. $validator->getErrors(); // Return a list of string containing the error messages.
Custom validation
$validator->customValidation("array", function (\Stantabcorp\Validator\CustomValidator $customValidator) { $customValidator->getKey(); // The key (`array` in this case) $customValidator->getValue(); // The associated value // Mark the kay as invalid and add an error message. $customValidator->addError("This is an error message"); });
Testing
composer run-script test
统计信息
- 总下载量: 1.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-21