Welcome Guest, Not a member yet? Register   Sign In
Inexistant form_validation rule/callback silently passes TRUE
#1

[eluser]Pnux[/eluser]
Take these rules as an example:

Code:
$config["user_name_last"] =
array(
  array(
   'field'  => 'firstName',
   'label'  => 'First Name',
   'rules'  => 'callback_notAFunctionNamedLikeThis|max_length[2]'
  )
);

with this code on the controller:

Code:
$this->load->library('form_validation');
$r = $this->form_validation->run('user_name_last');
var_dump($r);exit;

If firstName is set to "hello world", the validation will return FALSE because its longer than 2 characters. But if firstName is set to "n", the validation will return TRUE. Same thing applies using

Code:
'rules'  => 'notARuleNamedLikeThis|max_length[2]'

The thing is the validation goes through without a problem and no error is displayed/logged. I consider this a bug as, along the way, a programmer can change the declaration of the rule/callback and forget to change it on the validation rules, leaving that rule obsolete and unnoticed until an issue arise. In my opinion, this should be prevented whenever possible; but what do you think?
#2

[eluser]CroNiX[/eluser]
Yes, this is a bug that has been fixed for the next release (or you can grab the code from Github)
#3

[eluser]Pnux[/eluser]
Thanks a lot for the fast reply, i fixed the existent callback/rule by adding it to MY_Form_validation for the time being. We'll fix the rest (if they are broken) when the next release comes.




Theme © iAndrew 2016 - Forum software by © MyBB