zzortell/zz-validation-extra-bundle
最新稳定版本:v1.0.2
Composer 安装命令:
composer require zzortell/zz-validation-extra-bundle
包简介
Provides a set of extras validation constraints.
README 文档
README
Get more validation constraints !
Installation
Step 1: Download the bundle using composer
Add the bundle by running:
composer require zzortell/zz-validation-extra-bundle
Step 2: Enable the bundle
<?php // app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Zz\ValidationExtraBundle\ZzValidationExtraBundle(), // ... ); } }
Step 3: Enjoy !
Usage
The Color constraint
Use the Color constraint like any validation constraint of the symfony/Validator component.
For example, with annotations:
<?php use Zz\ValidationExtraBundle\Validator\Constraints as Extras; class MyClass { /** * Simple usage: * @Extras\Color */ protected $color = '#222a6e'; /** * All options with theirs default values: * @Extras\Color(formats="All", message="The color supplied (%color%) is invalid (for formats: %formats%).", requireHash=true) */ protected $color = '#222a6e'; /** * Complex usage: * @Extras\Color({"hex", "cssname"}, requireHash=false) */ protected $color = '#222a6e'; }
Properties:
formats: is the default option. It can be a string or an array of strings. Values:"All"(string only),"Hex","Name"("HtmlName"+CssName""),"HtmlName",CssName"".message: Available variables:%color%,%formats%.requireHash: forhexcolors. Values:null(doesn't worry) or boolean.
You can also use the following constraints, inheriting of Color:
HexColorNameColorCssNameColorHtmlNameColor
For these constraints, message is the default option.
Don't hesitate to have a look on Validator/Constraints.
Notice
If you don't want to get future features and just use colors constraints, require only 1.0.* versions.
Every future features will increment the minor number.
Todo
In the 1.0 branch:
- Use services' tag system instead of keeping in memory the formats in Validator/Constraints/ColorValidator.php
- Add the support of rgb, rgba, hsl, hsla formats
- Add a webSafe property
In the 1.1 branch:
- Add a color format convertor ?
Contributing
If you have any idea for improving the bundle or if you find a bug, please post an issue. If you want to help me, especially for correcting my english, please don't hesitate.
Credits
This bundle his inspired by the ollietb's HexColor constraint and his validator.
License
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
A part of this bundle comes from ollieLtd/OhColorPickerTypeBundle. Please see this notice:
Resources/meta/NOTICE.md
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-11