<p>I just figured out the answer so I'm going to post it if anyone else is asking this question. Yii accepts aliases as well as function/class names when evaluating the rules function. When using <code>number</code> you're really <strong>using an alias</strong> that points to the <code>yii\validators\NumberValidator</code> class. <strong>See <code>yii2/validators/Validator.php</code> to see a list of default aliases created by Yii.</strong></p>

CC BY-SA 4.0
2018-11-10T22:02:31.607Z
Great that you got it solved! If it works, go ahead and mark your own answer as "correct" so that it shows up as a solved issue.
KSP
CC BY-SA 4.0
2018-11-10T21:27:10.480Z
2018-11-10T21:27:10.480Z
Mat Weaver
<p>Some of the changes in craft 3 have been killing me. I know Yii does validation using the public <code>rules</code> function. Here is a rules function I grabbed from the <strong>MatrixBlockType model.</strong></p>

<pre><code>function rules()
{
    return [
        [['id', 'fieldId', 'sortOrder'], 'number', 'integerOnly' =&gt; true],
    ];
}
</code></pre>

<p>My question is simple. I for the life of me can't find where the validator <code>number</code> is defined. I'm assuming it validates using Yii's <code>NumberValidator.php</code> function but can't verify that. Any ideas on <strong>where I can find the number validator?</strong></p>

<craft3><validation><yii>
Craft Rules and Validation
# Craft Rules and Validation

(Asked by: username_0 on 2018-11-10)

Some of the changes in craft 3 have been killing me. I know Yii does validation using the public rules function. Here is a rules function I grabbed from the MatrixBlockType model.
function rules()
{
    return [
        [['id', 'fieldId', 'sortOrder'], 'number', 'integerOnly' => true],
    ];
}

My question is simple. I for the life of me can't find where the validator number is defined. I'm assuming it validates using Yii's NumberValidator.php function but can't verify that. Any ideas on where I can find the number validator?

**Tags:** craft3, validation, yii


---

## 1 answers

### Answer by username_0 on 2018-11-10. Score: 2

I just figured out the answer so I'm going to post it if anyone else is asking this question. Yii accepts aliases as well as function/class names when evaluating the rules function. When using `number` you're really **using an alias** that points to the `yii\validators\NumberValidator` class. **See `yii2/validators/Validator.php` to see a list of default aliases created by Yii.**

> **Comments:**
> **username_1**: Great that you got it solved! If it works, go ahead and mark your own answer as "correct" so that it shows up as a solved issue.  

---

