Validation Application Block (Is it possibke to make VAB independent from the Object (Properties) to whom it need to validate)

Dec 8, 2014 at 2:13 PM
Validation Application Block (Is it possibke to make VAB independent from the Object (Properties) to whom it need to validate)

Like as We need to select property to tied up with validators. Is it necessary to select properties or DLL (having details of these properties).

Can't it be generic.
Dec 9, 2014 at 3:19 AM
I'm not sure I fully understand the question.

Are you talking about some sort of validation by convention? If so, there is nothing supported out of the box although you could build something to reflect on types and create validators at runtime or perhaps some sort of code generation. Although, I'm not sure how you would be able to determine what validations need to be applied to what properties (e.g. is a string required or not? Perhaps yes and no depending on the application context).

In terms of dependencies, using declarative XML configuration results in loose coupling between the code and the validation infrastructure (since there is no hard dependency). However, a hard dependency on data annotation attributes for entities (or using MetadataType) is a commonly used .NET approach (although one may argue against that approach depending on how "pure" you think POCOs should be).

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Dec 9, 2014 at 8:30 AM
Question is about Configuring Rules through Validation Application Block.

When you are configuring, we need to select specific type (DLL) and then select specific properties (as part of that DLL) in order to tied up with different rules.
then by selecting that property, we established different rules (validation) for that property.

Is it possible to generalize this without specifying type... rules are generic and not specific to type.

If not then is it possible to provide sort of dependency injection, loose coupling between types and validaiton rules.

If yes, please share specific link. thanks