What Validator should I use

Topics: Validation Application Block
Jul 17, 2012 at 10:20 AM

I'm using an object with 2 properties

public class foo

public int bar {...}

public bool error {...}

end class


Which validator can I use to raise validation error on bar property if error property is true?




Jul 18, 2012 at 5:00 AM

It sounds like you want to use the UI Validation Integration features.  Typically in those scenarios each UI control will validate with one property.  In a general scenario self validation can be used for inter-property validation but self validation is not supported with the UI integration.  A custom validator could probably handle what you want to do as well.

Can you expand on the scenario, technology and approach?

Randy Levy
Enterprise Library support engineer

Jul 18, 2012 at 11:59 AM
Edited Jul 19, 2012 at 6:35 AM

Yes, I want to use this in my WPF forms

my object is an order class.
I have properties for quantity, packageA and packageB and an error indicator
e.g. packageA countains 5 pieces and packageB contains 15 pieces

quantity packageA packageB error

10 ->    2              0              false
12 ->    2              0              true, quantity can not be split on a packaging unit
25 ->    2              1              false
16 ->    0              1              true, quantity can not be split on a packaging unit

and I'm displaying quantity, packageA and packageB on my form ( it's used in a listbox)

When assigend by quantity I'm calculating how quantity may split to the different packages




PS I use this in a MVVM WPF application. Validiation should used in model on properties from order class

Jul 24, 2012 at 3:54 AM

I don't think you can do what you want with the out of the box integration.

A custom validator might be able to achieve what you want depending on the complexity and dependencies.  Another approach might be to implement IDataErrorInfo to handle validation.

Randy Levy
Enterprise Library support engineer