CakePHP验证:: naturalNumber()不起作用

Good morning (at least in Arizona).

I am running a simple validation check on a Model. Nothing fancy.

$this->loadModel('Something');
$data = array(
    'foo_id' => '1',
    'bar' => 'John'
); 
$this->Something->save($data);

----------------------------------------

class Something extends AppModel {
    public $validate = array(
        'foo_id' => array(
            'notEmpty' => array(
                'rule' => 'notEmpty',
                'message' => 'Foo id is missing',
                'required' => true
            ),
            'naturalNumber' => array(
                'rule' => 'naturalNumber',
                'message' => 'Foo id must be greater than 0',
                'required' => true
            )
        )
    );
}

This should be easy but Something.foo_id always fails the natural number validation. Notice that Something.id is not defined, so save() should run an INSERT. I have confirmed the value is greater than 0 and have even forced it to be an integer. I'm out of ideas and would appreciate if anyone could hazard a guess at what's going on. Thanks a lot for the help.

if you take a look at the documentation ( http://book.cakephp.org/2.0/en/models/data-validation.html#Validation::naturalNumber ) or the upgrade guide ( http://book.cakephp.org/2.0/en/appendices/2-2-migration-guide.html ) you should be able to notice that this rule has been added in 2.2

so either upgrade or manually add this rule to your app model