Validation Rules

Validation Rules

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


Slayer posted on Wednesday, June 24, 2009

Hi

I asked a similar question the other day, but I did not structure my question very well.

Usually when I create an object, like Customer, the object state will be invalid. I would then set a few properties until all the validation rules have been satisfied. The other day I encountered an object, that also starts out as invalid, but the object must only become valid after a method has been executed.

What is the recommended way to handle this. Usually validation rules apply to properties. Should I create a 'fake' property and then execute the PropertyHasChanged('fake') in the method ?

Regards

rsbaker0 replied on Wednesday, June 24, 2009

One possibility is to have a "real" protected property that is set to true at the end of the method that must be executed.

Then you add a simple validation rule that is broken if the property is false, and passes otherwise.

No fakery required.

Copyright (c) Marimer LLC