Cakephp验证负金额

时间:2012-10-07 09:55:03

标签: cakephp

  1. 我正在尝试使用负金额来验证cakephp中的字段。但它不允许我输入负数
  2. 验证不会显示货币符号
  3. 这些是我的验证规则:

        'TotalAmount' => array(
                'money' => array(
                        'rule' => array('money', 'left'),
                        'message' => 'Enter a valid money amount.',
                        'allowEmpty' => false,
                        'required' => false,
                        //'last' => false, // Stop validation after this rule
                        //'on' => 'create', // Limit validation to 'create' or 'update' operations
                ),
                'notempty' => array(
                        'rule' => array('notempty'),
                        'message' => 'This field can not be empty',
                        //'allowEmpty' => false,
                        //'required' => true,
                        //'last' => false, // Stop validation after this rule
                        //'on' => 'create', // Limit validation to 'create' or 'update' operations
                )
        )
    

1 个答案:

答案 0 :(得分:0)

你最好创建自己的验证规则来处理这个问题 - 技术上钱不能消极(但我理解你需要它的理由)

点击此链接:

http://book.cakephp.org/2.0/en/models/data-validation.html#adding-your-own-validation-methods

基本上你的函数只需要返回true或false!