我想在控制器端使用自定义验证。我想在验证中使用 CI 的表单验证器。
注意:我将对 Web 服务使用该验证。(这就是为什么它将保持在控制器级别)
我试着这样做,它是可以接受的格式吗?
$this->form_validation->set_rules('$userFullName', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('$userNickName', 'UserNickname', 'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('$userEmail', 'Email', 'trim|valid_email');
$this->form_validation->set_rules('$userPassword', 'Password Confirmation', 'trim|required|alpha_numeric|min_length[5]|max_length[12]|');
if ($this->form_validation->run() == FALSE)
{
if(!$this->validate_member->set_message($userFullName,'userFullName', 'trim|required|min_length[5]|max_length[12]|xss_clean'))
{
$error_code = '102';
} else if (!$this->validate_member->set_message($userNickName,'userNickName', 'UserNickname', 'trim|required|min_length[5]|max_length[12]|xss_clean')){
$error_code = '103';
} else if (!$this->validate_member->set_message($userEmail, 'Email', 'trim|valid_email')){
$error_code = '104';
} else if(!$this->validate_member->set_message($userEmail, '$userPassword', 'Password Confirmation', 'trim|required|alpha_numeric|min_length[5]|max_length[12]|')){
$error_code = '105';
} else {
$error_code = '106';
}
任何建议将不胜感激..