<?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: When should I validate in controllers and not in models?</title>
	<atom:link href="http://blog.afoolishmanifesto.com/archives/819/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.afoolishmanifesto.com/archives/819</link>
	<description>fREWdiculous!</description>
	<lastBuildDate>Tue, 09 Mar 2010 02:34:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Why you should validate in your controllers and not your models &#124; A Foolish Manifesto</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-194</link>
		<dc:creator>Why you should validate in your controllers and not your models &#124; A Foolish Manifesto</dc:creator>
		<pubDate>Thu, 18 Jun 2009 04:29:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-194</guid>
		<description>[...] I got some responses based on my question yesterday about why validation shouldn&#8217;t be in the model of an MVC-based [...]</description>
		<content:encoded><![CDATA[<p>[...] I got some responses based on my question yesterday about why validation shouldn&#8217;t be in the model of an MVC-based [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amiri</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-193</link>
		<dc:creator>Amiri</dc:creator>
		<pubDate>Wed, 17 Jun 2009 21:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-193</guid>
		<description>An email address seems like something that could easily go in the model, and should. The &quot;earlier&quot; it is handled, the better. I guess there are types of validation where the line gets more fuzzy.</description>
		<content:encoded><![CDATA[<p>An email address seems like something that could easily go in the model, and should. The &#8220;earlier&#8221; it is handled, the better. I guess there are types of validation where the line gets more fuzzy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David E. Wheeler</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-192</link>
		<dc:creator>David E. Wheeler</dc:creator>
		<pubDate>Wed, 17 Jun 2009 15:04:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-192</guid>
		<description>Because you should do validation in the database. This is one of the primary things a relational database is designed to do, so take advantage of it!

Theory</description>
		<content:encoded><![CDATA[<p>Because you should do validation in the database. This is one of the primary things a relational database is designed to do, so take advantage of it!</p>
<p>Theory</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Sherohman</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-191</link>
		<dc:creator>Dave Sherohman</dc:creator>
		<pubDate>Wed, 17 Jun 2009 10:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-191</guid>
		<description>I&#039;ve seen a lot of people using different definitions of what&#039;s a &quot;model&quot; and what&#039;s a &quot;controller&quot;, so this could just be a terminology mismatch.

As I use the terms, in the context of a web app, the &quot;model&quot; includes all of the underlying business classes and the &quot;controller&quot; is responsible solely for mapping data from the model into the view (templates) to generate a page.  Under that usage, then, yes, all validation is the model&#039;s job.

To someone else, though, the &quot;model&quot; may only be the database (and perhaps a thin OO layer around it), while the classes encapsulating business rules fall into their definition of &quot;controller&quot;.  By those definitions, validation clearly falls into the controller&#039;s realm.  (If you&#039;re using Catalyst with &quot;model&quot; classes that have been auto-generated by DBIC from your database schema without having added methods to them that go beyond simple database pass-through accessors, then you&#039;re probably using these definitions.)

What really matters is that you know where your invariant rules and logic - the things which would apply to all applications in the system if you were to write more than one - live.  All non-application-specific validation should go there also, regardless of whether you call it a &quot;model&quot; or a &quot;controller&quot;.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve seen a lot of people using different definitions of what&#8217;s a &#8220;model&#8221; and what&#8217;s a &#8220;controller&#8221;, so this could just be a terminology mismatch.</p>
<p>As I use the terms, in the context of a web app, the &#8220;model&#8221; includes all of the underlying business classes and the &#8220;controller&#8221; is responsible solely for mapping data from the model into the view (templates) to generate a page.  Under that usage, then, yes, all validation is the model&#8217;s job.</p>
<p>To someone else, though, the &#8220;model&#8221; may only be the database (and perhaps a thin OO layer around it), while the classes encapsulating business rules fall into their definition of &#8220;controller&#8221;.  By those definitions, validation clearly falls into the controller&#8217;s realm.  (If you&#8217;re using Catalyst with &#8220;model&#8221; classes that have been auto-generated by DBIC from your database schema without having added methods to them that go beyond simple database pass-through accessors, then you&#8217;re probably using these definitions.)</p>
<p>What really matters is that you know where your invariant rules and logic &#8211; the things which would apply to all applications in the system if you were to write more than one &#8211; live.  All non-application-specific validation should go there also, regardless of whether you call it a &#8220;model&#8221; or a &#8220;controller&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zbigniew Lukasiak</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-190</link>
		<dc:creator>Zbigniew Lukasiak</dc:creator>
		<pubDate>Wed, 17 Jun 2009 08:40:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-190</guid>
		<description>Important part of the problem are the error messages, for the display you need different messages than for the back end.  I guess you could have a dictionary to translate them (and that would also be a good start for i18n) - but that&#039;s additional complication.   I think the advice to have model side validation is a good one - but it needs a lot of infrastructure to make it usable.</description>
		<content:encoded><![CDATA[<p>Important part of the problem are the error messages, for the display you need different messages than for the back end.  I guess you could have a dictionary to translate them (and that would also be a good start for i18n) &#8211; but that&#8217;s additional complication.   I think the advice to have model side validation is a good one &#8211; but it needs a lot of infrastructure to make it usable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moritz Onken</title>
		<link>http://blog.afoolishmanifesto.com/archives/819/comment-page-1#comment-189</link>
		<dc:creator>Moritz Onken</dc:creator>
		<pubDate>Wed, 17 Jun 2009 05:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.afoolishmanifesto.com/?p=819#comment-189</guid>
		<description>Because the model is not aware of the current user.
Depending on her locale the format of Date/Time inputs is different. Depending on his roles, he may or may not set or change columns.</description>
		<content:encoded><![CDATA[<p>Because the model is not aware of the current user.<br />
Depending on her locale the format of Date/Time inputs is different. Depending on his roles, he may or may not set or change columns.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
