Cross field validation rules

Cross field validation rules

Old forum URL:

MBonner posted on Wednesday, August 05, 2009

I'm trying to implement some cross field validation rules where some calculated total of field1 + field2 + field3 needs to be
My issue is that when field4 gets updated, I need to rerun my validation rule on the total again to make sure the updated check value didn't make the total break the validation rule. Is there any easy way to run the validations on a specific field (or better yet, a specific validation rule) from inside another field's setter?


- Mike :-)

RockfordLhotka replied on Wednesday, August 05, 2009

You can set up dependencies between properties within the business rule subsystem. This is discussed in the Expert 2008 Business Objects book, and I'm pretty sure I cover it in the CSLA .NET for Silverlight video series as well.

You can set up your calculation as a business rule and trigger it to be run when any of the four properties is changed.

MBonner replied on Saturday, August 08, 2009

Yes, the book deals with this in Chapter 11 (pp. 339-340 for the C# edition) and in Chapter 17 (pp. 526-527.) You probably do address that in video 5 or 6, I've only had the time to watch the first 4 so far (great series so far btw!)

In case someone else finds this post in a search, the solution is to use the ValidationRules.AddDependentProperty method which sets up the cross property dependency.

Thanks for the pointer! Sorry for posting such basic questions, it's been a while since I've had the chance to use CSLA as I've been stuck doing legacy app support rather than new development for a while now.

- Mike :-)

Copyright (c) Marimer LLC