Strategy Pattern in .NET: Listing 3

Employee Validation Strategy

Listing 3: EmployeeValidationStrategy.cs

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

About the Author

Eric Vogel is a Senior Software Developer for Red Cedar Solutions Group in Okemos, Michigan. 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 [email protected].

comments powered by Disqus

Featured

Subscribe on YouTube