/// <summary> /// Initializes a new instance of the <see cref="EmployeeValidator"/> class. /// </summary> public EmployeeValidator(IEmployeeDataSvc employeeDataSvc) { _employeeDataSvc = Check.NotNull(employeeDataSvc, nameof(employeeDataSvc)); Property(x => x.Email).Mandatory().Common(CommonValidators.Email); Property(x => x.FirstName).Mandatory().Common(CommonValidators.PersonName); Property(x => x.LastName).Mandatory().Common(CommonValidators.PersonName); Property(x => x.Gender).Mandatory().IsValid(); Property(x => x.Birthday).Mandatory().CompareValue(CompareOperator.LessThanEqual, ExecutionContext.Current.Timestamp.AddYears(-18), errorText: "Birthday is invalid as the Employee must be at least 18 years of age."); Property(x => x.StartDate).Mandatory().CompareValue(CompareOperator.GreaterThanEqual, new DateTime(1999, 01, 01, 0, 0, 0, DateTimeKind.Utc), "January 1, 1999"); Property(x => x.PhoneNo).Mandatory().Common(CommonValidators.PhoneNo); Property(x => x.Address).Entity(_addressValidator); Property(x => x.EmergencyContacts).Collection(maxCount: 5, item: CollectionRuleItem.Create(_emergencyContactValidator).UniqueKeyDuplicateCheck(ignoreWhereUniqueKeyIsInitial: true)); }
public EmployeeManager(IEmployeeDataSvc dataService) { _dataService = Check.NotNull(dataService, nameof(dataService)); EmployeeManagerCtor(); }