ajd/ajd-validation-respect-adapter
Composer 安装命令:
composer require ajd/ajd-validation-respect-adapter
包简介
AJD validation respect validation rules adpater
README 文档
README
Respect Validation adapter for AJD validation
Description
Respect Validation adapter for AJD validation so that you could use repect validation's rules with the unique features that ajd validation provides.
Getting Started
Installing
-
composer require ajd/ajd-validation-respect-adapter -
after installing add the package to AJD validation as shown by the example below
use AJD_validation\AJD_validation; $v->addPackages([ AjdRespect\AjdRespectServiceProvider::class ]);
- adding package is usally done in the bootsraping of your application
Documentation
API
- After installing and adding the package you now have access to respect validation rules
- To access respect validation rules prefix the respect validation rule with
respect[respect_rule_name]
use AJD_validation\AJD_validation; $v = new AJD_validation; $v ->respectnotempty() ->respectalnum('*') ->check('respectrules', ''); // outputs error /* All of the required rules must pass for "Respectrules". - Respectrules must not be empty - Respectrules must contain only letters (a-z), digits (0-9) and "*" */ $v ->getValidator() ->respectnotempty() ->respectalnum('*') ->validate(''); // returns false $v ->respectnotempty() ->respectalnum('*') ->check('respectrules', 'a'); // validation passes $v ->getValidator() ->respectnotempty() ->respectalnum('*') ->validate('a'); // returns true
- if you are going to use special rules of respect validation which requries Respect's \Respect\Validation\Validatable as a satisfier/argument
- Use
$v->getRespectValidator()(this method comes with the package) method which returns \Respect\Validation\Validator instance. - Then enclosed all the \Respect\Validation\Validatable in an array.
- When using
$v->getRespectValidator()you must call respect validation rules like as discussed here:
Respect validation documentation
- Use
use AJD_validation\AJD_validation; $v = new AJD_validation; $v ->respectnoneof( [ $v->getRespectValidator() ->NotEmpty() ->alnum('*') ] ) ->check('respectrules', 'a'); // outputs error /* All of the required rules must pass for "Respectrules". - None of these rules must pass for Respectrules */ $v ->getValidator() ->respectnoneof( [ $v->getRespectValidator() ->NotEmpty() ->alnum('*') ] ) ->validate('a'); // returns false $v ->respectnoneof( [ $v->getRespectValidator() ->NotEmpty() ->alnum('*') ] ) ->check('respectrules', ''); // validation passes $v ->getValidator() ->respectnoneof( [ $v->getRespectValidator() ->NotEmpty() ->alnum('*') ] ) ->validate(''); // returns true
See respect validation documentation here - Respect validation documentation
Authors
Contributors names and contact info Aj Doc (thedoctorisin17@gmail.com)
Version History
- 0.1 (master)
- Initial Release
Links
- See also:
Acknowledgments
Inspiration, code snippets, etc.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-04