andrebaltieri / FluentValidator

Fluent Validator is a fluent way to use Notification Pattern with your entities
122 stars 40 forks source link

Make Contract be generic, instead of by injection. #23

Open thiagolunardi opened 6 years ago

thiagolunardi commented 6 years ago

Then:

public class CustomerContract : Contract<Customer>
{
    public CustomerContract()
    {
        Contract
            .Requires()
            .HasMinLen(customer => customer.FirstName, 3, "FirstName", "First Name should have at least 3 chars")
            .HasMaxLen(customer => customer.FirstName, 3, "FirstName", "First Name should not have more than 3 chars")
            .HasMinLen(customer => customer.LastName, 3, "LastName", "Last Name should have at least 3 chars")
            .HasMaxLen(customer => customer.LastName, 3, "LastName", "Last Name should not have more than 3 chars");
    }
}