4.1.4.8 decimal

This rule ensures that the data is a valid decimal number. A parameter can be passed to specify the number of digits required after the decimal point. If no parameter is passed, the data will be validated as a scientific float, which will cause validation to fail if no digits are found after the decimal point.

var $validate = array(
    'price' => array(
        'rule' => array('decimal', 2)
    )
);
  1. var $validate = array(
  2. 'price' => array(
  3. 'rule' => array('decimal', 2)
  4. )
  5. );