<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Morris &#34;Mojo&#34; Jones &#187; bean validation</title>
	<atom:link href="http://mojo.whiteoaks.com/tag/bean-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://mojo.whiteoaks.com</link>
	<description>Code Monkey, Astronomer, Photographer, Bridge Player</description>
	<lastBuildDate>Mon, 31 Oct 2011 01:03:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>&#8220;Bean Validation&#8221; Emmanuel Bernard</title>
		<link>http://mojo.whiteoaks.com/2009/03/20/bean-validation-emmanuel-bernard/</link>
		<comments>http://mojo.whiteoaks.com/2009/03/20/bean-validation-emmanuel-bernard/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 22:39:15 +0000</pubDate>
		<dc:creator>Morris Jones</dc:creator>
				<category><![CDATA[Software and Systems]]></category>
		<category><![CDATA[bean validation]]></category>
		<category><![CDATA[TheServerSide]]></category>

		<guid isPermaLink="false">http://mojo.whiteoaks.com/?p=128</guid>
		<description><![CDATA[<p class="wp-caption-text">Registration lobby at Caesar&#39;s Palace</p>
<p>Notes from TheServerSide Java Symposium March 2009</p>
<p>What&#8217;s the point of a bean validation framework? I&#8217;ve been wondering that for a while now. Emmanuel points out that it&#8217;s mostly to keep from repeating yourself in code.</p>
<p>Validation itself is obvious &#8230; keep crap out of the database, apply constraints to data fields, give [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_139" class="wp-caption alignright" style="width: 262px"><em><em><img class="size-full wp-image-139" title="img_20431" src="http://mojo.whiteoaks.com/wp-content/uploads/2009/03/img_20431.jpg" alt="Registration lobby at Caesar's Palace" width="252" height="168" /></em></em><p class="wp-caption-text">Registration lobby at Caesar&#39;s Palace</p></div>
<p><em>Notes from TheServerSide Java Symposium March 2009</em></p>
<p>What&#8217;s the point of a bean validation framework? I&#8217;ve been wondering that for a while now. Emmanuel points out that it&#8217;s mostly to keep from repeating yourself in code.</p>
<p>Validation itself is obvious &#8230; keep crap out of the database, apply constraints to data fields, give feedback to users.</p>
<p>Where do we apply validation constraints? Take a typical application stack:</p>
<p>client -&gt; presentation layer -&gt; business layer -&gt; data access layer -&gt; database</p>
<p>He begins by giving several examples of how constraints are applied to day, down to the DDL in the database which might specify a column length and a &#8220;not null&#8221; constraint. These constraints are typically duplicated all the way up the application chain, and really bad when the constraints don&#8217;t agree!</p>
<p>He proposes a uniform way to express a constraint, a standard way to validate constraints, and a bridge for constraints out of Java land, exposing constraints to the outside world.</p>
<p>Annotations are the key, extending the type system, right next to the class definition. Hence JSR 303 for bean validation. Example field annotations for validation:</p>
<pre>@NotNull
@Size(max=30, message="longer than {max} characters")</pre>
<p>The spec also calls for validating subsets of data fields by specifying groups, or partial validation. The spec defines groups by using interfaces. Clumsy, but workable.</p>
<p>Custom constraints can be built out by creating a custom annotation with an expressive name, extending the @Constraint type. You can compose a group of existing validators from the library into a new annotation.</p>
<p>(So far I&#8217;ve only been a consumer of annotations. Maybe soon it will be time for me to start creating them as well. I usually try to avoid meta-programming, even though it can be fun.)</p>
]]></content:encoded>
			<wfw:commentRss>http://mojo.whiteoaks.com/2009/03/20/bean-validation-emmanuel-bernard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

