Oct 18 2008
Unique validation rule in CakePHP 1.2
In this post I will show an example of how apply the unique validation rule in CakePHP 1.2. It’s very important to do in some cases, like saving users. You must make sure that the username is unique in your system. Lets see how it works:
var $validate = array(
'username' => array(
'rule' => array('isUnique'),
'message' => 'Username already in use.'
)
);
I wrote a custom function to validate it, but thanks to Dia now I know the built-in validation rule.

October 19th, 2008 at 09:05
CakePHP 1.2 has a built-in unique validation rule :
var $validate = array(
‘myField’ => array(
‘rule’ => ‘isUnique’,
‘message’ => ‘data already exists’
));
October 19th, 2008 at 12:04
Thanks for the information, I didn’t see this rule. But I already fixed the post to use it. It’s better then custom functions.
November 7th, 2008 at 14:57
it´s a super code!
onde eu posso pegar a “tag cloud”? muito bem sacada…
pode mandar pro email.
até mais pessoal. congratulations!