I am using a mySql DECIMAL(12,4) column to hold price values (seeing how that’s what Magento uses). I want to validate them in my ActiveRecord model using Yii’s CValidator rules, but I’m not quite sure how to do it.
I assume I can do it with the CTypeValidator set to “float”, but I wanted to see how other folks are doing this. I don’t see an actual “currency” validator. Maybe I should just validate the length?
array('price', 'type', 'type'=>'float'),
or
array('price', 'length', 'max'=>17), // 12 + 4 + . = 17?
Suggestions and examples? Thanks!
I myself used the:
rule… if needed, you can also use or combine the previous with the ‘match’ validator