Re: CakePHP 1.2 RC3 - Problem with alphaNumeric validation
Hey James. I had the problem with alphanumeric never validated on a production server. I found out that cake's alphaNumeric validation uses the /u regex parameter which has a bug in PHP 5.1.6: http://bugs.php.net/bug.php?id=42298 So I wrote my own alphaNumeric: app_model.php: / * validate alphanumeric for php compatibility sanity */ function myAlphaNumeric($data) { $val = array_shift(array_values($data)); if (ereg('[^A-Za-z0-9]', $val)) { return false; } else { return true; } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: CakePHP 1.2 RC3 - Problem with alphaNumeric validation
I've figured out the problem. In my controller, when I call the save() method on the model, I also set the third parameter, fieldList, for the fields to save. I found a change in RC3 which meant that only the fields that are supplied in the fieldList array are validated. In RC2 all the fields were validated, even those not present in the fieldList array. The fieldList array was only used to say which fields should be saved. That was frustrating, but I'm glad we figured it out. Thanks for your help everyone. On Oct 12, 4:30 pm, John Jackson <[EMAIL PROTECTED]> wrote: > Sorry for the continued posting, but I've discovered it's cake/libs/ > model/model.php which changes between 7689 and 7690 and stops my > validation working. There are lots of changes between these revisions > so I'm wondering if anyone could help me work out if it's a bug or if > I need to change my code. Thanks in advance. > > On Oct 12, 4:04 pm, John Jackson <[EMAIL PROTECTED]> wrote: > > > After a bit of investigation, I have found that the exact same > > validation code works in revision 7689, but not in 7690. > > > On Oct 12, 3:44 pm, John Jackson <[EMAIL PROTECTED]> wrote: > > > > I have the same problem here with 1.2 RC3. It's odd because my > > > username and email validation appears to be working as expect, but my > > > validation on the password fields isn't working. My validation rules > > > are as follows: > > > > var $validate = array > > > ( > > > 'email' => array > > > ( > > > 'valid' => array > > > ( > > > 'rule' => 'email', > > > 'required' => true, > > > 'message' => 'Please enter a valid email address', > > > ), > > > 'unique' => array > > > ( > > > 'rule' => 'isUnique', > > > 'required' => true, > > > 'message' => 'This email address has already been > > > used', > > > ) > > > ), > > > 'username' => array > > > ( > > > 'unique' => array > > > ( > > > 'rule' => 'isUnique', > > > 'required' => true, > > > 'message' => 'This username has already been > > > taken, sorry!', > > > ), > > > 'alphanumeric' => array > > > ( > > > 'rule' => 'alphaNumeric', > > > 'required' => true, > > > 'message' => 'Username must be alphanumeric', > > > ), > > > 'empty' => array > > > ( > > > 'rule' => array('custom', '/\S+/'), > > > 'required' => true, > > > 'message' => 'Please enter your username', > > > ) > > > ), > > > 'new_password' => array > > > ( > > > 'rule' => array('minLength', '6'), > > > 'message' => 'Password must be at least 6 characters > > > long', > > > 'required' => true, > > > ), > > > 'confirm_password' => array > > > ( > > > 'empty' => array > > > ( > > > 'rule' => array('minLength', '6'), > > > 'message' => 'Password must be at least 6 > > > characters long', > > > 'required' => true, > > > ), > > > 'identical' => array > > > ( > > > 'rule' => array('identicalFieldValues', > > > 'new_password'), > > > 'message' => 'Passwords do not match', > > > 'required' => true, > > > ) > > > ) > > > ); > > > > Interestingly, even if I change the rule for the password fields to > > > the custom regex I'm using for the username field, it still doesn't > > > work, yet the username field validation does work. I have tested the > > > same code on svn revision 7673 and it works. So somewhere between > > > revision 7673 and 7692 there has either been a bug or a change in > > > functionality introduced. > > > > On Oct 5, 7:18 pm, James Pearson <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > > > I upgraded my project from RC2 to RC3 today, and all went smoothly > > > > except for 1 area, validation. > > > > > I have a User model, with the following validation: (a sample) > > > > > var $validate = array( > > > > > 'first_name' => array( > > > > 'alphanumeric' => array( > > > > 'rule' => 'alphaNumeric', > > > > 'message' => 'Your name can > > > > only contain letters.', > > > > ),
Re: CakePHP 1.2 RC3 - Problem with alphaNumeric validation
Sorry for the continued posting, but I've discovered it's cake/libs/ model/model.php which changes between 7689 and 7690 and stops my validation working. There are lots of changes between these revisions so I'm wondering if anyone could help me work out if it's a bug or if I need to change my code. Thanks in advance. On Oct 12, 4:04 pm, John Jackson <[EMAIL PROTECTED]> wrote: > After a bit of investigation, I have found that the exact same > validation code works in revision 7689, but not in 7690. > > On Oct 12, 3:44 pm, John Jackson <[EMAIL PROTECTED]> wrote: > > > I have the same problem here with 1.2 RC3. It's odd because my > > username and email validation appears to be working as expect, but my > > validation on the password fields isn't working. My validation rules > > are as follows: > > > var $validate = array > > ( > > 'email' => array > > ( > > 'valid' => array > > ( > > 'rule' => 'email', > > 'required' => true, > > 'message' => 'Please enter a valid email address', > > ), > > 'unique' => array > > ( > > 'rule' => 'isUnique', > > 'required' => true, > > 'message' => 'This email address has already been > > used', > > ) > > ), > > 'username' => array > > ( > > 'unique' => array > > ( > > 'rule' => 'isUnique', > > 'required' => true, > > 'message' => 'This username has already been taken, > > sorry!', > > ), > > 'alphanumeric' => array > > ( > > 'rule' => 'alphaNumeric', > > 'required' => true, > > 'message' => 'Username must be alphanumeric', > > ), > > 'empty' => array > > ( > > 'rule' => array('custom', '/\S+/'), > > 'required' => true, > > 'message' => 'Please enter your username', > > ) > > ), > > 'new_password' => array > > ( > > 'rule' => array('minLength', '6'), > > 'message' => 'Password must be at least 6 characters long', > > 'required' => true, > > ), > > 'confirm_password' => array > > ( > > 'empty' => array > > ( > > 'rule' => array('minLength', '6'), > > 'message' => 'Password must be at least 6 > > characters long', > > 'required' => true, > > ), > > 'identical' => array > > ( > > 'rule' => array('identicalFieldValues', > > 'new_password'), > > 'message' => 'Passwords do not match', > > 'required' => true, > > ) > > ) > > ); > > > Interestingly, even if I change the rule for the password fields to > > the custom regex I'm using for the username field, it still doesn't > > work, yet the username field validation does work. I have tested the > > same code on svn revision 7673 and it works. So somewhere between > > revision 7673 and 7692 there has either been a bug or a change in > > functionality introduced. > > > On Oct 5, 7:18 pm, James Pearson <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > I upgraded my project from RC2 to RC3 today, and all went smoothly > > > except for 1 area, validation. > > > > I have a User model, with the following validation: (a sample) > > > > var $validate = array( > > > > 'first_name' => array( > > > 'alphanumeric' => array( > > > 'rule' => 'alphaNumeric', > > > 'message' => 'Your name can only > > > contain letters.', > > > ), > > > 'between' => array( > > > 'rule' => array('between', 1, 15), > > > 'message' => 'You must supply > > > your first name', > > > 'required' => true > > > ) > > > ), > > > 'last_name' => array( > > > 'alphanumeric' => array( > > > 'rule' => 'alphaNumeric', > > > 'message' => 'Your name can only > > > contain letters.', > > >
Re: CakePHP 1.2 RC3 - Problem with alphaNumeric validation
After a bit of investigation, I have found that the exact same validation code works in revision 7689, but not in 7690. On Oct 12, 3:44 pm, John Jackson <[EMAIL PROTECTED]> wrote: > I have the same problem here with 1.2 RC3. It's odd because my > username and email validation appears to be working as expect, but my > validation on the password fields isn't working. My validation rules > are as follows: > > var $validate = array > ( > 'email' => array > ( > 'valid' => array > ( > 'rule' => 'email', > 'required' => true, > 'message' => 'Please enter a valid email address', > ), > 'unique' => array > ( > 'rule' => 'isUnique', > 'required' => true, > 'message' => 'This email address has already been > used', > ) > ), > 'username' => array > ( > 'unique' => array > ( > 'rule' => 'isUnique', > 'required' => true, > 'message' => 'This username has already been taken, > sorry!', > ), > 'alphanumeric' => array > ( > 'rule' => 'alphaNumeric', > 'required' => true, > 'message' => 'Username must be alphanumeric', > ), > 'empty' => array > ( > 'rule' => array('custom', '/\S+/'), > 'required' => true, > 'message' => 'Please enter your username', > ) > ), > 'new_password' => array > ( > 'rule' => array('minLength', '6'), > 'message' => 'Password must be at least 6 characters long', > 'required' => true, > ), > 'confirm_password' => array > ( > 'empty' => array > ( > 'rule' => array('minLength', '6'), > 'message' => 'Password must be at least 6 characters > long', > 'required' => true, > ), > 'identical' => array > ( > 'rule' => array('identicalFieldValues', > 'new_password'), > 'message' => 'Passwords do not match', > 'required' => true, > ) > ) > ); > > Interestingly, even if I change the rule for the password fields to > the custom regex I'm using for the username field, it still doesn't > work, yet the username field validation does work. I have tested the > same code on svn revision 7673 and it works. So somewhere between > revision 7673 and 7692 there has either been a bug or a change in > functionality introduced. > > On Oct 5, 7:18 pm, James Pearson <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I upgraded my project from RC2 to RC3 today, and all went smoothly > > except for 1 area, validation. > > > I have a User model, with the following validation: (a sample) > > > var $validate = array( > > > 'first_name' => array( > > 'alphanumeric' => array( > > 'rule' => 'alphaNumeric', > > 'message' => 'Your name can only > > contain letters.', > > ), > > 'between' => array( > > 'rule' => array('between', 1, 15), > > 'message' => 'You must supply your > > first name', > > 'required' => true > > ) > > ), > > 'last_name' => array( > > 'alphanumeric' => array( > > 'rule' => 'alphaNumeric', > > 'message' => 'Your name can only > > contain letters.', > > ), > > 'between' => array( > > 'rule' => array('between', 1, 15), > > 'message' => 'You must supply your > > last name', > > 'required' => true > > ) > > ) > > ); > > > In CakePHP 1.2 RC3 both first_name and last_name fail to validate with > > valid values (or any value infact). > > > I've traced this down to the re
Re: CakePHP 1.2 RC3 - Problem with alphaNumeric validation
I have the same problem here with 1.2 RC3. It's odd because my username and email validation appears to be working as expect, but my validation on the password fields isn't working. My validation rules are as follows: var $validate = array ( 'email' => array ( 'valid' => array ( 'rule' => 'email', 'required' => true, 'message' => 'Please enter a valid email address', ), 'unique' => array ( 'rule' => 'isUnique', 'required' => true, 'message' => 'This email address has already been used', ) ), 'username' => array ( 'unique' => array ( 'rule' => 'isUnique', 'required' => true, 'message' => 'This username has already been taken, sorry!', ), 'alphanumeric' => array ( 'rule' => 'alphaNumeric', 'required' => true, 'message' => 'Username must be alphanumeric', ), 'empty' => array ( 'rule' => array('custom', '/\S+/'), 'required' => true, 'message' => 'Please enter your username', ) ), 'new_password' => array ( 'rule' => array('minLength', '6'), 'message' => 'Password must be at least 6 characters long', 'required' => true, ), 'confirm_password' => array ( 'empty' => array ( 'rule' => array('minLength', '6'), 'message' => 'Password must be at least 6 characters long', 'required' => true, ), 'identical' => array ( 'rule' => array('identicalFieldValues', 'new_password'), 'message' => 'Passwords do not match', 'required' => true, ) ) ); Interestingly, even if I change the rule for the password fields to the custom regex I'm using for the username field, it still doesn't work, yet the username field validation does work. I have tested the same code on svn revision 7673 and it works. So somewhere between revision 7673 and 7692 there has either been a bug or a change in functionality introduced. On Oct 5, 7:18 pm, James Pearson <[EMAIL PROTECTED]> wrote: > Hello, > > I upgraded my project from RC2 to RC3 today, and all went smoothly > except for 1 area, validation. > > I have a User model, with the following validation: (a sample) > > var $validate = array( > > 'first_name' => array( > 'alphanumeric' => array( > 'rule' => 'alphaNumeric', > 'message' => 'Your name can only > contain letters.', > ), > 'between' => array( > 'rule' => array('between', 1, 15), > 'message' => 'You must supply your > first name', > 'required' => true > ) > ), > 'last_name' => array( > 'alphanumeric' => array( > 'rule' => 'alphaNumeric', > 'message' => 'Your name can only > contain letters.', > ), > 'between' => array( > 'rule' => array('between', 1, 15), > 'message' => 'You must supply your > last name', > 'required' => true > ) > ) > ); > > In CakePHP 1.2 RC3 both first_name and last_name fail to validate with > valid values (or any value infact). > > I've traced this down to the regex in /cake/lib/validations.php, > around line 170. > > My development machine, OS-X, PHP 5.25 this issue does not occur. > On the server, CentOS, PHP 5.1.6 this does occur. > > If this is a setting in PHP, or a known issue with PHP 5.1.6 please > let me know. > > James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakeP
CakePHP 1.2 RC3 - Problem with alphaNumeric validation
Hello, I upgraded my project from RC2 to RC3 today, and all went smoothly except for 1 area, validation. I have a User model, with the following validation: (a sample) var $validate = array( 'first_name' => array( 'alphanumeric' => array( 'rule' => 'alphaNumeric', 'message' => 'Your name can only contain letters.', ), 'between' => array( 'rule' => array('between', 1, 15), 'message' => 'You must supply your first name', 'required' => true ) ), 'last_name' => array( 'alphanumeric' => array( 'rule' => 'alphaNumeric', 'message' => 'Your name can only contain letters.', ), 'between' => array( 'rule' => array('between', 1, 15), 'message' => 'You must supply your last name', 'required' => true ) ) ); In CakePHP 1.2 RC3 both first_name and last_name fail to validate with valid values (or any value infact). I've traced this down to the regex in /cake/lib/validations.php, around line 170. My development machine, OS-X, PHP 5.25 this issue does not occur. On the server, CentOS, PHP 5.1.6 this does occur. If this is a setting in PHP, or a known issue with PHP 5.1.6 please let me know. James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---