Validation from Config / Order of execution

Topics: Validation Application Block
May 5, 2008 at 7:28 PM
Hello,

I am using the Validation.Validate(object) to validate my business object which I have place Methods that populate certain property values via a data access layer/class. In instituting these business rules in this manner I have come onto a rule that requires the evaluation of a property value, which I am dependent upon having been populated during the Validation.Validate method.

So what I need to understand is the order in which the .Validate fires against the Method types (when setting them up in the .config). Is it as simple as the order by which they exist in the app.config (don't think so as I have already tested that by placing one in front of the other and the order was stil the same), or is it Alpha, or just random....

Hope my quesiton is clear.

Thanks,
John
May 16, 2008 at 3:38 PM
Hi John,

If I understand correctly, some methods you use to validate have side effects that affect validation of other validated language elements. That's a shaky situation IMO, but in any case the order in which the specified validations are executed is:
  • The type level
  • Properties, in the order in which they are specified in the configuration file (but this is a side effect of how configuration is deserialized)
  • Fields, in the order in which they are specified in the configuration file
  • Methods, in the order in which they are specified in the configuration file
  • Self validation methods

What do you mean by "fires against the method types"? Is you question about the relative order of validations for methods, or methos vs. properties?

Fernando


jminker wrote:
Hello,

I am using the Validation.Validate(object) to validate my business object which I have place Methods that populate certain property values via a data access layer/class. In instituting these business rules in this manner I have come onto a rule that requires the evaluation of a property value, which I am dependent upon having been populated during the Validation.Validate method.

So what I need to understand is the order in which the .Validate fires against the Method types (when setting them up in the .config). Is it as simple as the order by which they exist in the app.config (don't think so as I have already tested that by placing one in front of the other and the order was stil the same), or is it Alpha, or just random....

Hope my quesiton is clear.

Thanks,
John