2017 © Pedro Peláez
 

yii2-extension yii2-calc-validator

Math expression validator for Yii2

image

zhuravljov/yii2-calc-validator

Math expression validator for Yii2

  • Saturday, April 18, 2015
  • by Zhuravljov
  • Repository
  • 1 Watchers
  • 4 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

Yii2 Calc Validator

Math expression validator without using eval() for Yii2., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

$ composer require zhuravljov/yii2-calc-validator

or add, (*4)

"zhuravljov/yii2-calc-validator": "*"

to the require section of your composer.json file., (*5)

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., (*6)

For example:, (*7)

  • 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., (*8)

More details about calculation of expressions., (*9)

The Versions

18/04 2015

dev-master

9999999-dev https://github.com/zhuravljov/yii2-calc-validator

Math expression validator for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

extension validator yii math calculator

18/04 2015

1.0

1.0.0.0 https://github.com/zhuravljov/yii2-calc-validator

Math expression validator for Yii2

  Sources   Download

BSD-3-Clause

The Requires

 

by Roman Zhuravlev

extension validator yii math calculator