<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Validation with CakePHP 1.2</title>
	<atom:link href="http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 16 Mar 2010 17:17:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-142323</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 17 Dec 2009 16:26:05 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-142323</guid>
		<description>@pablo: Good to hear you could resolve your issue :)</description>
		<content:encoded><![CDATA[<p>@pablo: Good to hear you could resolve your issue :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo005</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-142321</link>
		<dc:creator>pablo005</dc:creator>
		<pubDate>Thu, 17 Dec 2009 16:06:07 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-142321</guid>
		<description>Sorry, already found the problem.

The problem is that within the rule &#039;between&#039; was this:

&lt;code&gt;
&#039;between&#039; =&gt; array (
    &#039;rule&#039; =&gt; array ( &#039;between&#039;, 4, 10),
    &#039;allowEmpty&#039; =&gt; false,
    &#039;required&#039; =&gt; false,
    &#039;last&#039; =&gt; true
) 
&lt;/code&gt;

In theory when the field is left empty should display the error message defined for &#039;between&#039;. But no, it shows the default error message. But if completed less than 4 characters then it displays the correct error message. The solution is to create another rule only for &#039;allowEmpty&#039; with an error message.

Thank you very much for your help.</description>
		<content:encoded><![CDATA[<p>Sorry, already found the problem.</p>
<p>The problem is that within the rule &#8216;between&#8217; was this:</p>
<pre><code>'between' =&gt; array (
    'rule' =&gt; array ( 'between', 4, 10),
    'allowEmpty' =&gt; false,
    'required' =&gt; false,
    'last' =&gt; true
)</code></pre>
<p>In theory when the field is left empty should display the error message defined for &#8216;between&#8217;. But no, it shows the default error message. But if completed less than 4 characters then it displays the correct error message. The solution is to create another rule only for &#8216;allowEmpty&#8217; with an error message.</p>
<p>Thank you very much for your help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-142318</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 17 Dec 2009 15:41:33 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-142318</guid>
		<description>@pablo: Your code looks good. What CakePHP version do you use?</description>
		<content:encoded><![CDATA[<p>@pablo: Your code looks good. What CakePHP version do you use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo005</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-142259</link>
		<dc:creator>pablo005</dc:creator>
		<pubDate>Wed, 16 Dec 2009 18:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-142259</guid>
		<description>Hi, 

I need to translate the error messages. I have this in my model: 

&lt;code&gt;
var $validate = array(
       &#039;username&#039; =&gt; array(
           &#039;between&#039; =&gt; array(
              &#039;rule&#039; =&gt; array(&#039;between&#039;, 4, 10),
              &#039;last&#039; =&gt; true
           ),
           &#039;unique&#039; =&gt; array(
              &#039;rule&#039; =&gt; &#039;isUnique&#039;
           )
      )
); 
&lt;/code&gt;

And this in my view: 
&lt;pre&gt;
&lt;code&gt;
echo $form-&gt;input(&#039;username&#039;, array(&#039;error&#039; =&gt; array(&#039;between&#039; =&gt; _(&#039;Between 4 and 10.&#039;, true), &#039;unique&#039; =&gt; _(&#039;Existing User&#039;, true))); 
&lt;/code&gt;
&lt;/pre&gt;
But do not show these error messages. Shown are the error messages by default. But if I put only an error message then it is displayed.
&lt;pre&gt;
&lt;code&gt;
echo $form-&gt;input(&#039;username&#039;, array(&#039;error&#039; =&gt; _(&#039;Between 4 and 10.&#039;, true))); 
&lt;/code&gt;
&lt;/pre&gt;
What may be happening. Is it a bug?. Does anyone have the same
problem?.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>I need to translate the error messages. I have this in my model: </p>
<pre><code>var $validate = array(
       'username' =&gt; array(
           'between' =&gt; array(
              'rule' =&gt; array('between', 4, 10),
              'last' =&gt; true
           ),
           'unique' =&gt; array(
              'rule' =&gt; 'isUnique'
           )
      )
);</code></pre>
<p>And this in my view: </p>
<pre>
<code>echo $form-&gt;input('username', array('error' =&gt; array('between' =&gt; _('Between 4 and 10.', true), 'unique' =&gt; _('Existing User', true)));</code>
</pre>
<p>But do not show these error messages. Shown are the error messages by default. But if I put only an error message then it is displayed.</p>
<pre>
<code>echo $form-&gt;input('username', array('error' =&gt; _('Between 4 and 10.', true)));</code>
</pre>
<p>What may be happening. Is it a bug?. Does anyone have the same<br />
problem?.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-137635</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 05 Oct 2009 14:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-137635</guid>
		<description>@asmad: I am not sure I understand you correctly, but if you want to validate whether the category_id is not null and greater than zero, than you could use a custom validation rule like:
&lt;code&gt;
public function isint($value, $params = array()) {
    return ( preg_match( &#039;/^\d+$/&#039;  , $value[&#039;category_id&#039;]) == 1 &amp;&amp; $value[&#039;category_id&#039;] &gt; 0);
}
&lt;/code&gt;

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@asmad: I am not sure I understand you correctly, but if you want to validate whether the category_id is not null and greater than zero, than you could use a custom validation rule like:<br />
<pre><code>public function isint($value, $params = array()) {
    return ( preg_match( '/^\d+$/'  , $value['category_id']) == 1 &amp;&amp; $value['category_id'] &gt; 0);
}</code></pre>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: asmad</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-137622</link>
		<dc:creator>asmad</dc:creator>
		<pubDate>Mon, 05 Oct 2009 07:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-137622</guid>
		<description>please give coding validate category_id if category_id NULL or equal to zero ! where category_id is foreign key</description>
		<content:encoded><![CDATA[<p>please give coding validate category_id if category_id NULL or equal to zero ! where category_id is foreign key</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-136006</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 10 Sep 2009 14:47:59 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-136006</guid>
		<description>@Celso: Well, if it is not required that the input strictly follows the format &quot;dd/mm/yyyy&quot; then you can use the built-in &quot;date&quot; validation rule:
&lt;pre&gt;
&lt;code&gt;
var $validate = array(&#039;thefield&#039; =&gt; array(&#039;rule&#039; =&gt; array(&#039;date&#039;, &#039;dmy&#039;)));
&lt;/code&gt;
&lt;/pre&gt;
However, if the input must exactly follow your format, then you either have to use the &quot;custom&quot; validation rule with a regex or you have to write your own validation method.

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@Celso: Well, if it is not required that the input strictly follows the format &#8220;dd/mm/yyyy&#8221; then you can use the built-in &#8220;date&#8221; validation rule:</p>
<pre>
<code>var $validate = array('thefield' =&gt; array('rule' =&gt; array('date', 'dmy')));</code>
</pre>
<p>However, if the input must exactly follow your format, then you either have to use the &#8220;custom&#8221; validation rule with a regex or you have to write your own validation method.</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Celso</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-135964</link>
		<dc:creator>Celso</dc:creator>
		<pubDate>Wed, 09 Sep 2009 15:57:06 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-135964</guid>
		<description>How validate with dd/mm/yyyy ???</description>
		<content:encoded><![CDATA[<p>How validate with dd/mm/yyyy ???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-134026</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 04 Aug 2009 15:08:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-134026</guid>
		<description>@Angeline: Hm, isn&#039;t it a &quot;missing view&quot; error? In that case use the &lt;a href=&quot;http://api.cakephp.org/class/controller#method-Controllerrender&quot; rel=&quot;nofollow&quot;&gt;render()&lt;/a&gt; method to display your view.

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@Angeline: Hm, isn&#8217;t it a &#8220;missing view&#8221; error? In that case use the <a href="http://api.cakephp.org/class/controller#method-Controllerrender" rel="nofollow">render()</a> method to display your view.</p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angeline</title>
		<link>http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/comment-page-3/#comment-134007</link>
		<dc:creator>Angeline</dc:creator>
		<pubDate>Tue, 04 Aug 2009 04:39:37 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/03/validation-with-cakephp-12/#comment-134007</guid>
		<description>Well, If I use setFlash, I get this error:

Please enter valid inputs
Not Found

Error: The requested address &#039;/users/register&#039; was not found on this server.


Because I do not have a separate ctp file for register or login. If the login or register  functions fail, I remain in the same page, that is /main/index or I move to /main/home.


So is there a way to bring those error messages in such conditions?</description>
		<content:encoded><![CDATA[<p>Well, If I use setFlash, I get this error:</p>
<p>Please enter valid inputs<br />
Not Found</p>
<p>Error: The requested address &#8216;/users/register&#8217; was not found on this server.</p>
<p>Because I do not have a separate ctp file for register or login. If the login or register  functions fail, I remain in the same page, that is /main/index or I move to /main/home.</p>
<p>So is there a way to bring those error messages in such conditions?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
