Remove a Validation Rule?

Remove a Validation Rule?

Old forum URL: forums.lhotka.net/forums/t/6446.aspx


jasona22 posted on Tuesday, February 17, 2009

I have 2 fields on a form.  For the sake of this discussion, lets assume Telephone Number and Email Address.  Either field can be populated; however at least one MUST be.

So the idea is that each field get a validation rule that requires its existance and when one is populated, the others validation rule is "removed".   However I cannot figure out how to do this.

I am used to objects having Add and Remove, Open and Close and other orthogonal concecpts.  However I cannot figure out how to remove a validation rule once you add it.

Any help would be appreciated.

 

Thanks

tmg4340 replied on Tuesday, February 17, 2009

You wouldn't remove a rule - you would create a custom rule method within your BO that checks both property values.  Then you can add the rule to both properties (or possibly use the dependency system), and the validation system should take care of the rest.

HTH

- Scott

Fintanv replied on Wednesday, February 18, 2009

ValidationRules.AddDependentProperty will allow the changing of property A to also fire the rules for property B.  You can have a rule that checks both properties and sets the error based on your criteria.  Add the rule to both properties and set them as being bi-directionally dependant. 

Copyright (c) Marimer LLC