[英]cakephp validation rules not firing
Given the following Controller: 给定以下控制器:
class UsersController extends AppController {
public function findUser() {
...
$this->User->findUser($this->request->query['u']);
...
}
}
And the following Model: 以及以下模型:
class User extends AppModel {
public $validate = array(
'username' => array(
'rule' => array('minLength', '8'),
'message' => 'Username must be at least 8 characters'
)
);
public function findUser($username) {
return $this->find('all', array(
'conditions' => array('username' => $username),
));
}
}
If for example I type this in the url: http://example.com/users/findUser?u=a
the validator does not get triggered. 例如,如果我在URL中键入以下内容:
http://example.com/users/findUser?u=a
: http://example.com/users/findUser?u=a
u=a验证器不会被触发。 Why? 为什么?
验证器用于插入或更新数据,而不用于查询数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.