Print Page | Close Window

A complicated validation scenario

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=881
Printed Date: 19-Apr-2024 at 12:14pm


Topic: A complicated validation scenario
Posted By: Matthew
Subject: A complicated validation scenario
Date Posted: 08-Jul-2008 at 5:01pm
At least its a bit complicated from my point of view, but I was hoping I could get some advice on how to handle it.

I have a business object "Customer" with fields like "Status", "AccountRep", and "SupportLevel."  There are several rules associated with Customer including the following two:
1. If Status = "New", then SupportLevel must = High
2. If Status = "New", then AccountRep cannot be null

In the GUI, Status is bound to a ComboBox.  When the user chooses "New" from the ComboBox is where my problem begins.  "New" is a valid choice for Status, so if AccountRep field is null, the rule is broken.  Status should not display an error, however, AccountRep should, but the rule really should be fired when Status is changed (I want to show the user visually when he changes the Status that he mush fill out AccountRep also).  And the rule should also be applied (in reverse I guess) when the user changes the AccountRep comboBox.

I guess my question is how to handle a situation where one field fires the rule, but the error should be displayed on another field?

If any of that needs clarification, please let me know :)
Thanks for any insight,
Matthew




Replies:
Posted By: GregD
Date Posted: 09-Jul-2008 at 10:56am
Matthew:
 
Any rule involving more than one property should be applied only at instance validation, not in response to the setting of an individual property (pre- or post-set validation). In other words, the values of the two (or more) properties that are involved in the rule should not be tested for correctness until you are validating the entire object. This permits either value to be set freely, independently of the other; but the freedom ends when the instance is validated in its entirety.
 
Greg Dunn
IdeaBlade
 



Print Page | Close Window