Enterprise Library Validation Block - Validate nullable properties?
Posted
by Robert MacLean
on Stack Overflow
See other posts from Stack Overflow
or by Robert MacLean
Published on 2009-01-20T06:24:39Z
Indexed on
2010/06/16
19:32 UTC
Read the original article
Hit count: 285
I am trying to come up with a validation for a nullable property, like int?
Example
[RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)]
int? Age { get; set; }
However if I set Age to null validation fails because it doesn't fall in the range, I know I need an [ValidatorComposition(CompositionType.Or)] as well, but what else should I use?
© Stack Overflow or respective owner