<?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: Generic Validation</title>
	<atom:link href="http://www.udidahan.com/2007/04/30/generic-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com/2007/04/30/generic-validation/</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Sat, 11 Feb 2012 15:16:10 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-37479</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Thu, 07 Oct 2010 19:56:18 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-37479</guid>
		<description>balazs,

You&#039;d have a separate validator object for each of those entities.</description>
		<content:encoded><![CDATA[<p>balazs,</p>
<p>You&#8217;d have a separate validator object for each of those entities.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: balazs</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-37475</link>
		<dc:creator>balazs</dc:creator>
		<pubDate>Mon, 04 Oct 2010 08:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-37475</guid>
		<description>Nice article, still I have one question.

If I call a method on an entity and inside the method I do some business rule checking, how can I pass the validation results (and messages) from the domain layer to the presentation layer!

Assume that a service method tries to execute 2 methods on 2 separate entities. Both entities could/should be validated (business rules like: allow adding another order, unless previous order is not fulfilled or so) and results from both entities should be passed to the user.

Throwing a custom exception when rules fail won&#039;t help (cause we would loose - not execute - validations from the second entity)...

Any good practices/advices? Thanx.</description>
		<content:encoded><![CDATA[<p>Nice article, still I have one question.</p>
<p>If I call a method on an entity and inside the method I do some business rule checking, how can I pass the validation results (and messages) from the domain layer to the presentation layer!</p>
<p>Assume that a service method tries to execute 2 methods on 2 separate entities. Both entities could/should be validated (business rules like: allow adding another order, unless previous order is not fulfilled or so) and results from both entities should be passed to the user.</p>
<p>Throwing a custom exception when rules fail won&#8217;t help (cause we would loose &#8211; not execute &#8211; validations from the second entity)&#8230;</p>
<p>Any good practices/advices? Thanx.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-36495</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Thu, 30 Jul 2009 16:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-36495</guid>
		<description>Al,

You might want to consider using a domain event instead of an exception. I&#039;ve written this up here:

http://www.udidahan.com/2009/06/14/domain-events-salvation/</description>
		<content:encoded><![CDATA[<p>Al,</p>
<p>You might want to consider using a domain event instead of an exception. I&#8217;ve written this up here:</p>
<p><a href="http://www.udidahan.com/2009/06/14/domain-events-salvation/" rel="nofollow">http://www.udidahan.com/2009/06/14/domain-events-salvation/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-36494</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Thu, 30 Jul 2009 11:35:27 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-36494</guid>
		<description>Thanks Udi, it makes sense. Validation in my opinion should be done in two places.
1. Before the service call - Somewhere in presentation via validation service call to be able to display validation errors in the UI.
2. In the service - In the HaveCustomerRepGiveDiscount method in this case. I will throw an exception (ValidationException or anything) here to rollback a transaction (call may be a part of a transaction).

But I have not attended your workshop yet! I am looking forward to the end to end solution in the workshop. :)</description>
		<content:encoded><![CDATA[<p>Thanks Udi, it makes sense. Validation in my opinion should be done in two places.<br />
1. Before the service call &#8211; Somewhere in presentation via validation service call to be able to display validation errors in the UI.<br />
2. In the service &#8211; In the HaveCustomerRepGiveDiscount method in this case. I will throw an exception (ValidationException or anything) here to rollback a transaction (call may be a part of a transaction).</p>
<p>But I have not attended your workshop yet! I am looking forward to the end to end solution in the workshop. <img src='http://www.udidahan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-36491</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 29 Jul 2009 10:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-36491</guid>
		<description>Al,

Great hearing from you.

The service layer receives a message/invocation indicating the wish of a customer rep to give a discount to an order, here&#039;s the code of that object:

public void HaveCustomerRepGiveDiscount(Guid orderId, Guid customerRepId, double discount)
{
var rep = this.Session.Get&lt;ICustomerServiceRepGivesDiscount&gt;(customerRepId);
var order = this.Session.Get&lt;Order&gt;(orderId);

rep.GiveDiscount(order, discount);
}

Then, when the ORM is going to persist the changes, it can look for the validators.

Does that answer your question?</description>
		<content:encoded><![CDATA[<p>Al,</p>
<p>Great hearing from you.</p>
<p>The service layer receives a message/invocation indicating the wish of a customer rep to give a discount to an order, here&#8217;s the code of that object:</p>
<p>public void HaveCustomerRepGiveDiscount(Guid orderId, Guid customerRepId, double discount)<br />
{<br />
var rep = this.Session.Get&lt;ICustomerServiceRepGivesDiscount&gt;(customerRepId);<br />
var order = this.Session.Get&lt;Order&gt;(orderId);</p>
<p>rep.GiveDiscount(order, discount);<br />
}</p>
<p>Then, when the ORM is going to persist the changes, it can look for the validators.</p>
<p>Does that answer your question?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-36478</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Mon, 27 Jul 2009 16:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-36478</guid>
		<description>Hi Udi,

I will be attending your workshop in Austin December 09 so looking forward to the whole week.

I have a question about your latest comment about:
IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt;

What exactly is the process ICustomerServiceRepGivesDiscount? Is it something like a service operation to be validated like below or do you mean it in a different context?

class CustomerServices : ICustomerService {
	void GiveDiscountToCustomer(ICustomerServiceRepGivesDiscount activity) { }
}

interface ICustomerServiceRepGivesDiscount {
	Customer Customer { get; }
	Discount Discount { get; }
}

CustomerServiceRepGivesDiscount : ICustomerServiceRepGivesDiscount {
	// interface implementation and process specific behavior //
}

CustomerServiceRepGivesDiscountValidator : IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt; {

}

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Udi,</p>
<p>I will be attending your workshop in Austin December 09 so looking forward to the whole week.</p>
<p>I have a question about your latest comment about:<br />
IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt;</p>
<p>What exactly is the process ICustomerServiceRepGivesDiscount? Is it something like a service operation to be validated like below or do you mean it in a different context?</p>
<p>class CustomerServices : ICustomerService {<br />
	void GiveDiscountToCustomer(ICustomerServiceRepGivesDiscount activity) { }<br />
}</p>
<p>interface ICustomerServiceRepGivesDiscount {<br />
	Customer Customer { get; }<br />
	Discount Discount { get; }<br />
}</p>
<p>CustomerServiceRepGivesDiscount : ICustomerServiceRepGivesDiscount {<br />
	// interface implementation and process specific behavior //<br />
}</p>
<p>CustomerServiceRepGivesDiscountValidator : IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt; {</p>
<p>}</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-28625</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Sat, 02 Aug 2008 09:14:06 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-28625</guid>
		<description>Craig,

Glad you liked them.

The processes in the system are really just representations of use cases:

IRegularUserChangesOwnAddress
IAdministratorCancelsBatch
ICustomerServiceRepGivesDiscount

Then, it&#039;s not just about validating the given entity by itself, but in the given context. When going to give a discount to a customer for an order, our service layer would go look for:

IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt;

When designing your system around tasks rather than classic CRUD, these techniques become much more straight-forward since you don&#039;t have to infer the process from a generic UPDATE call.</description>
		<content:encoded><![CDATA[<p>Craig,</p>
<p>Glad you liked them.</p>
<p>The processes in the system are really just representations of use cases:</p>
<p>IRegularUserChangesOwnAddress<br />
IAdministratorCancelsBatch<br />
ICustomerServiceRepGivesDiscount</p>
<p>Then, it&#8217;s not just about validating the given entity by itself, but in the given context. When going to give a discount to a customer for an order, our service layer would go look for:</p>
<p>IValidator&lt;Order, ICustomerServiceRepGivesDiscount&gt;</p>
<p>When designing your system around tasks rather than classic CRUD, these techniques become much more straight-forward since you don&#8217;t have to infer the process from a generic UPDATE call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CraigCav</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-28586</link>
		<dc:creator>CraigCav</dc:creator>
		<pubDate>Fri, 01 Aug 2008 11:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-28586</guid>
		<description>Udi,
I&#039;ve really enjoyed reading many of your articles and I found this one particularly interesting. I have however, struggled to follow the proposed solution to the issue of tying validation rules to specific processes. Could you perhaps describe what the IProcess interface (and perhaps a sample implementation) would look like? Many thanks,
Craig</description>
		<content:encoded><![CDATA[<p>Udi,<br />
I&#8217;ve really enjoyed reading many of your articles and I found this one particularly interesting. I have however, struggled to follow the proposed solution to the issue of tying validation rules to specific processes. Could you perhaps describe what the IProcess interface (and perhaps a sample implementation) would look like? Many thanks,<br />
Craig</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-28203</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Sat, 26 Jul 2008 06:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-28203</guid>
		<description>Colin,

That kind of validation is usually done at the XSD / Service Layer level.</description>
		<content:encoded><![CDATA[<p>Colin,</p>
<p>That kind of validation is usually done at the XSD / Service Layer level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Jack</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-28166</link>
		<dc:creator>Colin Jack</dc:creator>
		<pubDate>Fri, 25 Jul 2008 20:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-28166</guid>
		<description>As always thanks for replying and I think it now makes a lot of sense as you&#039;re still managing to keep some validation in the entities. 

Just one small question to follow up, if the presentation model is doing simple validation (length/range) is that validation repeated in the associated domain model classes?</description>
		<content:encoded><![CDATA[<p>As always thanks for replying and I think it now makes a lot of sense as you&#8217;re still managing to keep some validation in the entities. </p>
<p>Just one small question to follow up, if the presentation model is doing simple validation (length/range) is that validation repeated in the associated domain model classes?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-27568</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Thu, 17 Jul 2008 20:59:50 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-27568</guid>
		<description>Carel, Colin,

The kind of validations are those which are really business rules:

Regular customers can&#039;t order more than $10K per month.
Orders can&#039;t be accepted for discontinued products.
etc.

However, if you are using a presentation model - a different set of objects than those used in and around persistence, you can put real validation rules on them:

String lengths, value ranges, etc.

Those things which are process dependent or user dependent may be better handled by external validators.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Carel, Colin,</p>
<p>The kind of validations are those which are really business rules:</p>
<p>Regular customers can&#8217;t order more than $10K per month.<br />
Orders can&#8217;t be accepted for discontinued products.<br />
etc.</p>
<p>However, if you are using a presentation model &#8211; a different set of objects than those used in and around persistence, you can put real validation rules on them:</p>
<p>String lengths, value ranges, etc.</p>
<p>Those things which are process dependent or user dependent may be better handled by external validators.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Colin Jack</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-27413</link>
		<dc:creator>Colin Jack</dc:creator>
		<pubDate>Wed, 16 Jul 2008 10:57:11 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-27413</guid>
		<description>I just re-read this blog article, as always great stuff. However I have the same question as Carel, what validation do you leave in the entity?</description>
		<content:encoded><![CDATA[<p>I just re-read this blog article, as always great stuff. However I have the same question as Carel, what validation do you leave in the entity?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carel Lotz</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-1540</link>
		<dc:creator>Carel Lotz</dc:creator>
		<pubDate>Tue, 01 May 2007 19:10:36 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-1540</guid>
		<description>Sort of - the part of matching the validation rules to the specific process I understand, but it still feels like you are moving out the core business logic into externalised IValidator classes which should really belong on the domain object itself.  Granted you could have a Validate method on a base Entity that does the same as the Validate on the IEntityView, but that still invokes the business rules on these externalised Validator classes.

What kind of validations will remain of the domain objects?</description>
		<content:encoded><![CDATA[<p>Sort of &#8211; the part of matching the validation rules to the specific process I understand, but it still feels like you are moving out the core business logic into externalised IValidator classes which should really belong on the domain object itself.  Granted you could have a Validate method on a base Entity that does the same as the Validate on the IEntityView, but that still invokes the business rules on these externalised Validator classes.</p>
<p>What kind of validations will remain of the domain objects?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thesoftwaresimplist</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-1537</link>
		<dc:creator>thesoftwaresimplist</dc:creator>
		<pubDate>Tue, 01 May 2007 08:57:27 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-1537</guid>
		<description>Carel,

In a smart client scenario, let&#039;s say that the view was given a domain object class and bound its controls to it. Of course the domain object will make sure the data that its given is valid. The validators I&#039;m talking about here aren&#039;t necessarily taking that away from the domain.

The &quot;hard part&quot; that I&#039;m addressing here is matching these validation rules to specific processes - something the domain objects should know nothing about.

Does that answer your question?</description>
		<content:encoded><![CDATA[<p>Carel,</p>
<p>In a smart client scenario, let&#8217;s say that the view was given a domain object class and bound its controls to it. Of course the domain object will make sure the data that its given is valid. The validators I&#8217;m talking about here aren&#8217;t necessarily taking that away from the domain.</p>
<p>The &#8220;hard part&#8221; that I&#8217;m addressing here is matching these validation rules to specific processes &#8211; something the domain objects should know nothing about.</p>
<p>Does that answer your question?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carel Lotz</title>
		<link>http://www.udidahan.com/2007/04/30/generic-validation/comment-page-1/#comment-1536</link>
		<dc:creator>Carel Lotz</dc:creator>
		<pubDate>Tue, 01 May 2007 07:54:50 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/04/30/generic-validation/#comment-1536</guid>
		<description>Udi

Isn&#039;t this going a bit against the domain model pattern as you are pulling out the validation logic from your domain classes thus leaving it to basically contain only data? A bit like the anemic domain model anti-pattern?

Carel</description>
		<content:encoded><![CDATA[<p>Udi</p>
<p>Isn&#8217;t this going a bit against the domain model pattern as you are pulling out the validation logic from your domain classes thus leaving it to basically contain only data? A bit like the anemic domain model anti-pattern?</p>
<p>Carel</p>
]]></content:encoded>
	</item>
</channel>
</rss>

