sfw2/validator
最新稳定版本:7.2.0
Composer 安装命令:
composer require sfw2/validator
包简介
simple validation library
关键字:
README 文档
README
Simple validator-class for checking and validating post-data.
How to use it
First create a new Rulset
use SFW2\Validator\Ruleset; $rulset = new Ruleset();
Then add new rules for every $_REQUEST-param. For example if you want to check set param "home" is set and not empty write:
use SFW2\Validator\Validators\IsNotEmpty; $rulset->addNewRules('home', new IsNotEmpty());
if you want to check that "startTime" is a valid time write:
use SFW2\Validator\Validators\IsNotEmpty; use SFW2\Validator\Validators\IsTime; $rulset->addNewRules('startTime', new IsNotEmpty(), new IsTime());
After setup all rules simply create a validator-object with the given rules and call "validate". The first param contains the REQUEST-data, the second param returns the validated and sanitized vales from REQUEST by reference. The boolean return-value of validate indicates a successfully validation of all params
use SFW2\Validator\Validator; $validator = new Validator($rulset); $values = []; $error = $validator->validate($_POST, $values);
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 2025-01-12