Welcome Guest, Not a member yet? Register   Sign In
Custom validation rules not working. But only on Development server.
#1

[eluser]neal789[/eluser]
I’ve been having a problem where custom validation rules aren’t working on my development server however they are working on my local MAMP server. The custom validation file (ie. MY_Form_validation.php) is seen by the application. It even works on the development server if I overwrite a native CI validation rule. For example I can overwrite the "required()" function in MY_Form_validation.php and it works perfectly. However when I create a new rule it doesn’t seem to see it. I don’t get an error either. Nothing happens. It just seems to skip that validation item.

So for one particular form field I have the following validation rules
Code:
// A Snippet from my form validation config file.
...
                        array(
                            'field'    =>    'email_addresses',
                            'label'    =>    'Email Addresses',
                            'rules'    =>    'trim|required|valid_emails|max_emails[3]'
                            ),
...
So for the email_addresses field, “required” validates correctly, even if I overwrite the native CI rule with a custom rule in MY_Form_validation.php. "Valid_emails" rule also validates correctly. However the “max_emails” rule seems to be ignored as if it weren’t there, but only on my development server. On my local MAMP server it works perfectly.

Here is the max_emails function:
Code:
...
function max_emails($str, $val)
    {
        log_message('debug','MAX EMAILS: '.$str.' '.$val);
        if (strpos($str, ',') === FALSE)
        {
            return TRUE;
        }
        
        $i=0;
        foreach(explode(',', $str) as $email)
        {
            if (trim($email) != '' && $this->valid_email(trim($email)) !== FALSE)
            {
                $i++;
                if($i>$val) return FALSE;
            }
        }
        
        return TRUE;
    }
...
Whatever the problem is, it doesn’t seem to be specific to this rule since I’m having the same problem with a different custom validation rule on a different development branch.

Any thoughts/help/solution would be greatly appreciated.

Cheers,
Neal


Messages In This Thread
Custom validation rules not working. But only on Development server. - by El Forum - 08-01-2010, 02:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB