legatus/validator
Composer 安装命令:
composer require legatus/validator
包简介
An HTTP validation library for PSR-7
README 文档
README
An HTTP validation library for PSR-7
Installation
You can install the Validator component using Composer:
composer require legatus/validator
Quick Start
<?php $validator = Legatus\Http\Validator::build($psr7Request) ->body('id')->required()->uuid() ->body('name.first')->string()->required() ->body('name.middle')->string() ->body('name.last')->string()->required() ->body('password')->string()->required()->min(6)->password()->max(30) ->body('birthdate')->string()->date()->before('-18years') ->body('promo_code')->custom(new Legatus\Http\PromoCode()) // And instance of rule or a callable ->body('emails.*')->email() ->body('addresses.*.lineOne')->required()->string() ->body('addresses.*.lineTwo')->string() ->body('addresses.*.city')->required()->string() ->body('addresses.*.zip')->string() ->body('addresses.*.country')->enum(['CL', 'GB', 'US']) ->getValidator(); try { $data = $validator->validate(); } catch (Legatus\Http\ValidationFailed $e) { // $data = $e->getData(); } [$id, $name, $password, $birthDate, $promoCode, $emails, $addresses] = $data->values();
For more details you can check the online documentation here.
Project status & release process
While this library is still under development, it is well tested and should be stable enough to use in production environments.
The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented.
When a breaking change is introduced, a new 0.x version cycle is always started.
It is therefore safe to lock your project to a given release cycle, such as 0.2.*.
If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version.
Community
We still do not have a community channel. If you would like to help with that, you can let me know!
Contributing
Read the contributing guide to know how can you contribute to Legatus.
Security Issues
Please report security issues privately by email and give us a period of grace before disclosing.
About Legatus
Legatus is a personal open source project led by Matías Navarro Carter and developed by contributors.
统计信息
- 总下载量: 138
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-25