我有一个应该接受整数值的字段,它与另一个字段的总和应该是 100。为了做到这一点,我编写了这样的自定义方法。
'share' => array(
'share' => array(
'rule' => array('share'),
'message' => 'This field is required.',
'last' => true,
),
在这里,我想使用内置的验证方法来检查天气这个字段是数字的。
function share() {
if( $this->data['Model']['commission_type'] == "usage_based" ) {
// if($this->data['SmeCommission']['share']) { // Want to check this is a valid integer How can I built in Numeric validation here
// Next validation to sum is equal to 100 with another field in the data.
// }
} else {
return true;
}
}