Silverlight 4
The entire Simple.Validation library has been compiled for Silverlight and included in the NuGet package.
Conditional Property Validators
An If() method has been applied to the following property validators:
- EnumerablePropertyValidator
- RangePropertyValidator
- ReferencePropertyValidator
- StringPropertyValidator
When If() is called with the required Predicate, the validator will only apply when the condition specified by the Predicate is met.
[Test]
public void If_PredicateIsFalse_ShouldNotValidate()
{
// Arrange
var validator = Properties<Employee>
.For(e => e.Age)
.GreaterThanOrEqualTo(18)
.If(e => e.Age != -1)
;
// Act
var employee = new Employee()
{
Age = -1
};
var results = validator.Validate(employee);
// Assert
Assert.That(results, Is.Empty);
}
Posted on April 26, 2012, 4:08 pm By crmckenzie
No comments yet Categories: NuGet, Open Source Projects, Silverlight, Simple.Validation, Validation Tags: NuGet, Open Source Projects, Silverlight, Simple.Validation, Validation
