This project is read-only.

Explicit Specification

Use the default Specification registered in the Validation Catalog for that Type.

Check(p => p.Locations).Required().And.ForEachSpecification();

You can also supply a non-default Specification.
Check(p => p.Locations).Required().And.ForEachSpecification<Location, DeleteLocation>();

Inline Specification

Another approach is to build the specification inline.
Check(l => l.Schedule).Required(). And.ForEachSpecification(spec =>
        spec.Check(s => s.Open).Required().And.Between(0,24);
        spec.Check(s => s.Close).Required().And.Between(s => s.Open, 24);


Note that the ForEach rule validator required casting the parameter from object to the type in the collection.
Check(c => c.Contacts).Required().And.ForEach(c => ((Contact)c).Active);

Validation Collection Counts

Required vs Optional

The Required statement will verify that the collection is initialized, i.e. Not Null, and has at least one item in it. Additionally, there are a few validators for collection count.

Last edited May 26, 2011 at 11:19 PM by TechnoAg, version 5


No comments yet.