Strategy Pattern in .NET: Listing 4

Customer Validation Strategy

Listing 4: CustomerValidationStrategy.cs

using System;
 
namespace VSMStrategyPatternDemo
{
    public class CustomerValidationStrategy : IPersonValidationStrategy
    {
        public bool IsValid(Person person)
        {
            bool valid = false;
 
            if (person.FirstName != null && person.LastName != null && person.DateOfBirth < DateTime.Now.AddYears(13))
            {
                valid = true;
            }
 
            return valid;
        }
    }
}

About the Author

Eric Vogel is a Sr. Software Developer at Kunz, Leigh, & Associates in Okemos, MI. He is the president of the Greater Lansing User Group for .NET. Eric enjoys learning about software architecture and craftsmanship, and is always looking for ways to create more robust and testable applications. Contact him at vogelvision@gmail.com.