Reputation: 502
[['price'], 'integer', 'min' => 0, 'tooSmall' => 'Price cannot be less than 0'],
I have above rule in my model file. But while validating the model, return is true
while passed NULL
as price.
Any reason to this?
Upvotes: 0
Views: 874
Reputation: 9358
Set skipOnEmpty
to false
if you want to validate even when field empty, (by default it is set to true
).
[['price'], 'integer', 'skipOnEmpty' => false, 'min' => 0, 'tooSmall' => 'Price cannot be less than 0'],
Upvotes: 2