CodeIgniter Forums
Validation - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Validation (/thread-9626.html)

Validation - El Forum - 07-02-2008

Ok, so I have a profile page, and the user has the option to change their password or not, I was trying to use the validation class to do this, but I cannot figure out how to check if the password and confirmed password are the same, only if one of them is set. Is that possible with the validation class? Or would it not be because you need both variables?

Validation - El Forum - 07-02-2008

[eluser]Nima A.[/eluser]
oh ! I think , it's not a proper example of a FULL STACK framework functionality like CI
the main usage of full stack frameworks (vs. glue) is that it forces a structure for your program, (best solution for team based projects), and supply a foundation and a coding style , although it offers some functionalities such as validation, sending emails, etc ... but it's not the point !

your program may have various conditions and needs, I don't think it's a good choice to think
: " hmm, well I use a framework , so It should handle all of the situations with the help of it"
esp. when you are using FULL STACK frameworks, which means you care about the STRUCTURE of your program, not a utility class or function ,
I'm not interested on these capabilities in my program and prefer to create one (exactly regard to my needs) based on CI structure,

Validation - El Forum - 07-02-2008

if you wanna validate you can do this:

in any function of your choice and then
you have the following:
use an if-else statement to compare both you mail me back if not i will do some thing complete for and drop ok. call Ebot T.

Validation - El Forum - 07-02-2008

From the documentation:

$rules['password'] = "required|matches[passconf]";
$rules['passconf'] = "required";

Validation - El Forum - 07-02-2008

Quote:“ hmm, well I use a framework , so It should handle all of the situations with the help of it”

Wow... calm down there bud, I was just wondering if there was a way to do that in Code Igniter, I know how to do it myself without CI. I do not expect it to do everything for me, we had actually coded it without using any of the validation stuff, I was just wondering if there was a clever way to do it with CI.

Validation - El Forum - 07-02-2008

These are the rules of my profile editting form (not much profile info, just a name, email, login name and optional password changing).

$rules['name'] = 'required';
$rules['login'] = 'required';
$rules['email'] = 'required|valid_email';
$rules['curr_pw'] = 'callback_matches_curr_pw';
$rules['new_pw'] = 'matches[new_pw_check]';

Using these rules, the password changing is not required, but if they are set, they do get validated...

If you're interested in my custom callback method:
function matches_curr_pw($str) {
        if(empty($str)) {
            return true;
        } else {
            $curr_pw = md5($str);
            $this->db->where('ID', $this->session->userdata('user_id'));
            $qry = $this->db->get('users');
            $row = $qry->row_array();
            $db_pw = $row['paswoord'];
            if($curr_pw == $db_pw) {
                return true;
            } else {
                $this->validation->set_message('matches_curr_pw', 'Het %s veld komt niet overeen met het paswoord in de database.');
                return false;

Validation - El Forum - 07-02-2008

[eluser]Pascal Kriete[/eluser]
Well, it looks like satterie has you sorted.

@magpie that was neither helpful, nor did it relate to his question in any way.

Validation - El Forum - 07-02-2008

$rules['firstname'] = "trim|required|max_length[40]|xss_clean";
$rules['lastname'] = "trim|required|max_length[40]|xss_clean";
$rules['status'] = "required|xss_clean";
$rules['password'] = "trim|callback_password_check|xss_clean";
$rules['newpassword'] = "trim|matches[passconf]|xss_clean";
$rules['passconf'] = "trim|xss_clean";

This is what I had prior to this, but I have decided to move the password part out to another form as people would probably not be in the habit of changing their passwords as much as they would be changing other parts of the profile. Thanks for the help though!