How can i length on fields integer in rules of form ?
How can i length on fields integer in rules of form ?
Try this:
public function rules(){
return [
[['number_min'],'number','min'=>10],
[['number_max'],'number','max'=>100],
[['number_min_max'],'number','min'=>10,'max'=>100],
];
}
you use the core validator to check for min and max
#in your model file
#http://www.yiiframework.com/doc-2.0/guide-tutorial-core-validators.html#number
[['my_number'], 'number', 'min' => 0, 'max' => 16]
http://www.yiiframework.com/doc-2.0/guide-tutorial-core-validators.html
max: the upper limit (inclusive) of the value. If not set, it means the validator does not check the upper limit.
min: the lower limit (inclusive) of the value. If not set, it means the validator does not check the lower limit.
I want check length an integer.
for exsample :
if(strlen($phone) > 3){
}
If it is a phone number, I would define it as a string and use ‘string’ validator specifying the desired length. Or, I would consider using ‘match’ validator.