This project is read-only.
Basic Example

In the example below shows how rules can be applied to a Person object.

    public class Person
    {
        public string Name { get; set; }
        public string Phone { get; set; }
        public DateTime DateOfBirth { get; set; }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            Engine engine = new Engine();
            engine.For<Person>()
                    .Setup(p => p.DateOfBirth)
                        .MustBeLessThan(DateTime.Now)
                    .Setup(p => p.Name)
                        .MustNotBeNull()
                        .MustMatchRegex("^[a-zA-z]+$")
                    .Setup(p => p.Phone)
                        .MustNotBeNull()
                        .MustMatchRegex("^[0-9]+$");

            Person person = new Person();
            person.Name = "Bill";
            person.Phone = "1234214";
            person.DateOfBirth = new DateTime(1999, 10, 2);

            bool isValid = engine.Validate(person);
        }
    }

Last edited Aug 3, 2011 at 11:21 AM by athoma13, version 2

Comments

sedi Jul 22, 2015 at 5:18 AM 
Hi, this sample is outdated.. how can I update it?

Or could you possibly move this to GitHub?