Topics: Validation Application Block
Feb 3, 2010 at 12:03 AM

Hello, I would like to know if you like me to do the following validation.
Here is a sample class.
public class Test
[RangeValidator (min = 0, max = EndAge)]
public int StartAge;
[RangeValidator (min = StartAge, max = 200)]
public int EndAge;

I would like to use class properties to set the maximum or minimum, is that possible?

Feb 3, 2010 at 1:46 AM

It certainly is. 

public class Test
        [PropertyComparisonValidator("EndAge", ComparisonOperator.LessThanEqual, MessageTemplate="Start age should be less than end age.")]
        [RangeValidator(20, RangeBoundaryType.Inclusive, 0, RangeBoundaryType.Ignore)]
        public int StartAge { get; set; }

        [PropertyComparisonValidator("StartAge", ComparisonOperator.GreaterThanEqual, MessageTemplate="End age should be greater than start age.")]
        [RangeValidator(0, RangeBoundaryType.Ignore, 50, RangeBoundaryType.Inclusive)]
        public int EndAge { get; set; }

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.

Feb 3, 2010 at 3:08 PM

Thanks for your reply:)
One more question, I'm doing today in WPF validation as follows, my domain class implements IDataError, and in my form I do I define this:

- My domain class is the DataContext of the Grid form
- <Textbox Name="Teste" Text="{Binding Path=Nome, ValidatesOnDataErros=True, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"/>

I can do so using the Validation App Block?

Feb 4, 2010 at 6:24 AM


I'm not really familiar with the WPF and VAB integration, but I think these links would help:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.