Welcome Guest, Not a member yet? Register   Sign In
Multi-field validation callbacks, the "login" form problem, etc.
#8

[eluser]mycroes[/eluser]
[quote author="walesmd" date="1195088294"]
Quote:1) validation status - I don’t want the database check run if there are errors in either of the username or password fields, e.g. if the username isn’t a valid e-mail address, I don’t want to even try hitting the database.

The database check won't run as long as valid_email precedes the callback function within the rules of that field.

The Validation class only checks for one fault per rule and outputs the error of that one fault.[/quote]

I guess I wasn't clear enough, so I'll try to explain again with some code:
Code:
$rules['name'] = 'trim|required|exact_length[3]|callback__test';
$rules['password'] = 'trim|required|md5';


function _test($str) {
  echo $this->validation->password;
}

So what will this output? There's no documentation that says in what order the checks will execute, so we can have 2 cases:
1. first name is checked, during the check the _test function is called and the password isn't converted to md5 yet and the _test function will just print the text (password) entered by the user
2. password is checked first, after that name is checked and the _test function will output the md5 encrypted password.

See where I'm going? I didn't even think about your point that the $this->input->post('varname') was changed too, so my point of throwing stuff away the validator was doing was wrong, thanks for pointing that out. Still though, if you want to compare a entered password with the md5 encrypted password in a database you need to know if the validator already processed it and that's what missing. If we're able to set the order/sequence of checks (i.e. $rules = 'name(trim|required|exact_length[3])password(trim|required|md5)name(callback__test)') then this would be solved and the database will only be queried if all fields are valid.
Regards,

Michael


Messages In This Thread
Multi-field validation callbacks, the "login" form problem, etc. - by El Forum - 11-14-2007, 02:40 PM



Theme © iAndrew 2016 - Forum software by © MyBB