PHPackages                             zhuravljov/yii2-calc-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. zhuravljov/yii2-calc-validator

ActiveYii2-extension[Validation &amp; Sanitization](/categories/validation)

zhuravljov/yii2-calc-validator
==============================

Math expression validator for Yii2

1.0(11y ago)465BSD-3-ClausePHP

Since Apr 18Pushed 11y ago1 watchersCompare

[ Source](https://github.com/zhuravljov/yii2-calc-validator)[ Packagist](https://packagist.org/packages/zhuravljov/yii2-calc-validator)[ Docs](https://github.com/zhuravljov/yii2-calc-validator)[ RSS](/packages/zhuravljov-yii2-calc-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Yii2 Calc Validator
===================

[](#yii2-calc-validator)

Math expression validator without using `eval()` for Yii2.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require zhuravljov/yii2-calc-validator

```

or add

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

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#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](https://github.com/zhuravljov/calc/blob/master/README.md).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4048d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1656851?v=4)[Roman Zhuravlev](/maintainers/Zhuravljov)[@zhuravljov](https://github.com/zhuravljov)

---

Top Contributors

[![zhuravljov](https://avatars.githubusercontent.com/u/1656851?v=4)](https://github.com/zhuravljov "zhuravljov (4 commits)")

---

Tags

expressionmathvalidatoryii2validatormathextensionyiicalculator

### Embed Badge

![Health badge](/badges/zhuravljov-yii2-calc-validator/health.svg)

```
[![Health](https://phpackages.com/badges/zhuravljov-yii2-calc-validator/health.svg)](https://phpackages.com/packages/zhuravljov-yii2-calc-validator)
```

###  Alternatives

[yiibr/yii2-br-validator

Provide validations and features for brazilian localization

14103.2k4](/packages/yiibr-yii2-br-validator)[kdn/yii2-domain-validator

Domain name validator for Yii 2.

11122.3k1](/packages/kdn-yii2-domain-validator)[nepstor/yii2-datetime-compare-validator

Yii2 validator for compare datetime.

1283.7k1](/packages/nepstor-yii2-datetime-compare-validator)[mg-code/yii2-helpers

A collection of useful helper classes for Yii framework 2.0

2022.5k5](/packages/mg-code-yii2-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
