zhuravljov/yii2-calc-validator
最新稳定版本:1.0
Composer 安装命令:
composer require zhuravljov/yii2-calc-validator
包简介
Math expression validator for Yii2
README 文档
README
Math expression validator without using eval() for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require zhuravljov/yii2-calc-validator
or add
"zhuravljov/yii2-calc-validator": "*"
to the require section of your composer.json file.
Usage
public function rules() { return [ // ... // Rule for checking an expression ['amount1', 'zhuravljov\yii\validators\CalcValidator'], // Rule for checking an expressions with saving result of calculation ['amount2', 'zhuravljov\yii\validators\CalcValidator', 'resultAttribute' => 'amount2'], // ... ]; }
After adding this validator, expressions can be used in forms.
For example:
12.80 + 3.50 * 2- valid expression. Result:19.8.(2 + 2) * 2- valid expression. Result:8.(2 + 2- invalid expression.
This validator checks an expression and saves a result. And it can be used for currency fields or any numeric fields.
More details about calculation of expressions.
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-04-18