Monday, May 3, 2010

Alphanumeric validation in Cake PHP not working in CentOS

Today we got a bug.
Alphanumeric checking for first and last name fields were not working in the server and in my team member's systems. But it was working without in fault in my local system. Finally our team lead found the cause for the problem and fixed it.

Any guess what the problem was..

It was because of the operating system they had. They had Centos, and mine was Ubuntu. The version of centos that they had, doesn't support alphanumeric validation.

And the fixed code is:-
var $validate = array(
'first_name' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'First Name cannot be left blank',
'last' => true ),

'alphanumeric' => array(
'rule' => array('custom', '/^[a-z0-9]*$/i'), //this is the solved portion
'message' => 'First Name must only contain letters and numbers' ),
)
);

No comments:

Post a Comment