Hi.
I'm going to add a new way to map validators trough an implementation based on fluent-interface.
The FI is "strogly-typed" as Reflection but it is external (from the point of view of an entity-implementation) as XML.
For the ValidatorMode feature I would like to equate FI to Reflection (XmlOverAttributeClassMapping).
var v = new ValidationDef<Person>();
v.Define(x=>x.Name).AsNotNull().AsNotEmpty();
v.Define(x=>x.Surname).AsNotNull().AsNotEmpty().WithMaxLength(10).WithMinLength(3);
v.Define(x=>x.Assoc).MustBeValid();
and/or
public class PersonValidationDef : ValidationDef<Person>
{
public PersonValidationDef()
{
Define(x=>x.Name).AsNotNull().AsNotEmpty();
Define(x=>x.Surname).AsNotNull().AsNotEmpty().WithMaxLength(10).WithMinLength(3);
Define(x=>x.Assoc).MustBeValid();
}
}
Validators available will be strongly-typed that mean, for example, that giving a DateTime property (DateTime or DateTime?) only 2 validators will be available
var v = new ValidationDef<Person>();
v.Define(x=>x.BornDate). here you will see only IsInThePast and IsInTheFuture
Obviously each one may implements his extension methods.
Thoughts?