<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Cakephp unique validation in 1.2</title>
	<atom:link href="http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/</link>
	<description>useful divided by zero</description>
	<pubDate>Thu, 20 Nov 2008 00:43:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: useful</title>
		<link>http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-64</link>
		<dc:creator>useful</dc:creator>
		<pubDate>Fri, 07 Dec 2007 20:56:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-64</guid>
		<description>The reason I made my own unique check is that my version of 1.2 has a bug in isUnique and always returns 0 because it sets the field equal to the value.

Your way of validation seems to take a database call for each unique. If isUnique now works in 1.2 my ideal way to use it is:

var $validate = array( // validate our username and email
'username' =&gt; array('rule' =&gt; array('alphaNumeric')),
'email' =&gt; array('rule' =&gt; array('email'))
);
function beforeSave() {
$check = array('username','email'); // username and email are unique
return $this-&gt;isUnique($check); // isUnique returns #fields matching
}</description>
		<content:encoded><![CDATA[<p>The reason I made my own unique check is that my version of 1.2 has a bug in isUnique and always returns 0 because it sets the field equal to the value.</p>
<p>Your way of validation seems to take a database call for each unique. If isUnique now works in 1.2 my ideal way to use it is:</p>
<p>var $validate = array( // validate our username and email<br />
&#8216;username&#8217; => array(&#8217;rule&#8217; => array(&#8217;alphaNumeric&#8217;)),<br />
&#8216;email&#8217; => array(&#8217;rule&#8217; => array(&#8217;email&#8217;))<br />
);<br />
function beforeSave() {<br />
$check = array(&#8217;username&#8217;,'email&#8217;); // username and email are unique<br />
return $this->isUnique($check); // isUnique returns #fields matching<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: name</title>
		<link>http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-63</link>
		<dc:creator>name</dc:creator>
		<pubDate>Fri, 07 Dec 2007 16:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-63</guid>
		<description>my validation looks like:

var $validate = array('email' =&#62; array('not_unique' =&#62; array('rule' =&#62; array('validateUnique', 'field' =&#62; 'email')),'not_valid' =&#62; VALID_EMAIL,	'not_empty' =&#62; VALID_NOT_EMPTY));
	
function validateUnique($value, $field)
{
	$valid = false;
	$valid = $this-&#62;isUnique(array($field =&#62; $value));
	return $valid;
}</description>
		<content:encoded><![CDATA[<p>my validation looks like:</p>
<p>var $validate = array(&#8217;email&#8217; =&gt; array(&#8217;not_unique&#8217; =&gt; array(&#8217;rule&#8217; =&gt; array(&#8217;validateUnique&#8217;, &#8216;field&#8217; =&gt; &#8216;email&#8217;)),&#8217;not_valid&#8217; =&gt; VALID_EMAIL,	&#8216;not_empty&#8217; =&gt; VALID_NOT_EMPTY));</p>
<p>function validateUnique($value, $field)<br />
{<br />
	$valid = false;<br />
	$valid = $this-&gt;isUnique(array($field =&gt; $value));<br />
	return $valid;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: name</title>
		<link>http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-62</link>
		<dc:creator>name</dc:creator>
		<pubDate>Fri, 07 Dec 2007 15:27:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.usefulzero.com/2007/09/21/cakephp-unique-validation-in-12/#comment-62</guid>
		<description>hello, at the moment i have the same problem, but i think the model implements a method isUnique and this do the same

$this-&#62;model-&#62;isUnique('value');</description>
		<content:encoded><![CDATA[<p>hello, at the moment i have the same problem, but i think the model implements a method isUnique and this do the same</p>
<p>$this-&gt;model-&gt;isUnique(&#8217;value&#8217;);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
