This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
forked from 18F/dol-whd-14c
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from AppliedIS/feature-validation
Feature validation
- Loading branch information
Showing
74 changed files
with
2,428 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
DOL.WHD.Section14c.Business/Validators/AddressValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using DOL.WHD.Section14c.Domain.Models; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class AddressValidator : BaseValidator<Address>, IAddressValidator | ||
{ | ||
public AddressValidator() | ||
{ | ||
RuleFor(a => a.StreetAddress).NotEmpty(); | ||
RuleFor(a => a.City).NotEmpty(); | ||
RuleFor(a => a.State).NotEmpty(); | ||
RuleFor(a => a.ZipCode).NotEmpty(); | ||
RuleFor(a => a.County).NotEmpty(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
DOL.WHD.Section14c.Business/Validators/AlternateWageDataValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class AlternateWageDataValidator : BaseValidator<AlternateWageData>, IAlternateWageDataValidator | ||
{ | ||
public AlternateWageDataValidator() | ||
{ | ||
RuleFor(a => a.AlternateWorkDescription).NotEmpty(); | ||
RuleFor(a => a.AlternateDataSourceUsed).NotEmpty(); | ||
RuleFor(a => a.PrevailingWageProvidedBySource).NotNull(); | ||
RuleFor(a => a.DataRetrieved).NotEmpty(); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
DOL.WHD.Section14c.Business/Validators/ApplicationSubmissionValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Linq; | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class ApplicationSubmissionValidator : BaseValidator<ApplicationSubmission>, IApplicationSubmissionValidator | ||
{ | ||
public ApplicationSubmissionValidator(IEmployerValidator employerValidator, IHourlyWageInfoValidator hourlyWageInfoValidator, IPieceRateWageInfoValidator pieceRateWageInfoValidator, IWorkSiteValidator workSiteValidator, IWIOAValidator wioaValidator) | ||
{ | ||
// required | ||
RuleFor(a => a.RepresentativePayeeSocialSecurityBenefits).NotNull(); | ||
RuleFor(a => a.ProvidingFacilities).NotNull(); | ||
RuleFor(a => a.ReviewedDocumentation).NotNull(); | ||
RuleFor(a => a.EIN).NotEmpty(); | ||
RuleFor(a => a.ApplicationTypeId).NotNull(); | ||
RuleFor(a => a.HasPreviousApplication).NotNull(); | ||
RuleFor(a => a.HasPreviousCertificate).NotNull(); | ||
RuleFor(a => a.EstablishmentType).NotNull().Must(et => et.Any()); | ||
RuleFor(a => a.ContactName).NotEmpty(); | ||
RuleFor(a => a.ContactPhone).NotEmpty(); | ||
RuleFor(a => a.ContactEmail).NotEmpty(); | ||
RuleFor(a => a.PayTypeId).NotEmpty(); | ||
RuleFor(a => a.TotalNumWorkSites).NotNull(); | ||
RuleFor(a => a.Employer).NotNull().SetValidator(employerValidator); | ||
RuleFor(a => a.WorkSites).NotNull().Must(w => w.Any()).SetCollectionValidator(workSiteValidator); | ||
RuleFor(a => a.WIOA).NotNull().SetValidator(wioaValidator); | ||
|
||
// conditional required | ||
RuleFor(a => a.NumEmployeesRepresentativePayee) | ||
.NotEmpty() | ||
.When(a => a.RepresentativePayeeSocialSecurityBenefits.GetValueOrDefault()); | ||
|
||
When(a => a.ProvidingFacilities.GetValueOrDefault(), () => | ||
{ | ||
RuleFor(a => a.ProvidingFacilitiesDeductionType) | ||
.NotNull() | ||
.Must(p => p.Any()); | ||
RuleFor(a => a.ProvidingFacilitiesDeductionTypeOther) | ||
.NotEmpty() | ||
.When(a => a.ProvidingFacilitiesDeductionType != null && a.ProvidingFacilitiesDeductionType.Any(x => x.ProvidingFacilitiesDeductionTypeId == 20)); | ||
}); | ||
|
||
RuleFor(a => a.CertificateNumber) | ||
.NotEmpty() | ||
.When(a => a.HasPreviousCertificate.GetValueOrDefault()); | ||
|
||
RuleFor(a => a.HourlyWageInfo) | ||
.NotNull() | ||
.SetValidator(hourlyWageInfoValidator) | ||
.When(x => x.PayTypeId == 21 || x.PayTypeId == 23); | ||
|
||
RuleFor(a => a.PieceRateWageInfo) | ||
.NotNull() | ||
.SetValidator(pieceRateWageInfoValidator) | ||
.When(x => x.PayTypeId == 22 || x.PayTypeId == 23); | ||
|
||
// Other validation | ||
RuleFor(a => a.ContactEmail).EmailAddress(); | ||
RuleFor(a => a.WorkSites.Count) | ||
.Equal(a => a.TotalNumWorkSites.GetValueOrDefault()) | ||
.When(a => a.WorkSites != null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class BaseValidator<T> : AbstractValidator<T> where T : class | ||
{ | ||
public BaseValidator() | ||
{ | ||
CascadeMode = CascadeMode.StopOnFirstFailure; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
DOL.WHD.Section14c.Business/Validators/EmployeeValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class EmployeeValidator : BaseValidator<Employee>, IEmployeeValidator | ||
{ | ||
public EmployeeValidator() | ||
{ | ||
RuleFor(e => e.Name).NotEmpty(); | ||
RuleFor(e => e.PrimaryDisabilityId).NotNull(); | ||
RuleFor(e => e.WorkType).NotEmpty(); | ||
RuleFor(e => e.NumJobs).NotNull(); | ||
RuleFor(e => e.AvgWeeklyHours).NotNull(); | ||
RuleFor(e => e.AvgHourlyEarnings).NotNull(); | ||
RuleFor(e => e.PrevailingWage).NotNull(); | ||
RuleFor(e => e.ProductivityMeasure).NotNull(); | ||
RuleFor(e => e.CommensurateWageRate).NotEmpty(); | ||
RuleFor(e => e.TotalHours).NotNull(); | ||
RuleFor(e => e.WorkAtOtherSite).NotNull(); | ||
|
||
// conditional | ||
RuleFor(e => e.PrimaryDisabilityOther).NotEmpty().When(e => e.PrimaryDisabilityId == 38); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
DOL.WHD.Section14c.Business/Validators/EmployerValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class EmployerValidator : BaseValidator<EmployerInfo>, IEmployerValidator | ||
{ | ||
public EmployerValidator(IAddressValidator addressValidator, IWorkerCountInfoValidator workerCountInfoValidator) | ||
{ | ||
// required | ||
RuleFor(e => e.LegalName).NotEmpty(); | ||
RuleFor(e => e.HasTradeName).NotNull(); | ||
RuleFor(e => e.LegalNameHasChanged).NotNull(); | ||
RuleFor(e => e.PhysicalAddress).NotNull().SetValidator(addressValidator); | ||
RuleFor(e => e.HasDifferentMailingAddress).NotNull(); | ||
RuleFor(e => e.HasParentOrg).NotNull(); | ||
RuleFor(e => e.EmployerStatusId).NotNull(); | ||
RuleFor(e => e.IsEducationalAgency).NotNull(); | ||
RuleFor(e => e.FiscalQuarterEndDate).NotEmpty(); | ||
RuleFor(e => e.NumSubminimalWageWorkers).NotNull().SetValidator(workerCountInfoValidator); | ||
RuleFor(e => e.PCA).NotNull(); | ||
RuleFor(e => e.SCAId).NotNull(); | ||
RuleFor(e => e.EO13658Id).NotNull(); | ||
RuleFor(e => e.RepresentativePayee).NotNull(); | ||
RuleFor(e => e.TakeCreditForCosts).NotNull(); | ||
RuleFor(e => e.ProvidingFacilitiesDeductionTypeId).NotNull(); | ||
RuleFor(e => e.TemporaryAuthority).NotNull(); | ||
|
||
// conditional required | ||
RuleFor(e => e.TradeName).NotEmpty().When(e => e.HasTradeName.GetValueOrDefault()); | ||
RuleFor(e => e.PriorLegalName).NotEmpty().When(e => e.LegalNameHasChanged.GetValueOrDefault()); | ||
When(e => e.HasParentOrg.GetValueOrDefault(), () => | ||
{ | ||
RuleFor(e => e.ParentLegalName).NotEmpty(); | ||
RuleFor(e => e.ParentTradeName).NotEmpty(); | ||
RuleFor(e => e.ParentAddress).NotNull().SetValidator(addressValidator); | ||
RuleFor(e => e.SendMailToParent).NotNull(); | ||
}); | ||
RuleFor(e => e.EmployerStatusOther).NotEmpty().When(e => e.EmployerStatusId == 10); | ||
RuleFor(e => e.ProvidingFacilitiesDeductionTypeOther) | ||
.NotEmpty() | ||
.When(e => e.ProvidingFacilitiesDeductionTypeId == 20); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
DOL.WHD.Section14c.Business/Validators/HourlyWageInfoValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public class HourlyWageInfoValidator : WageTypeInfoValidator<HourlyWageInfo>, IHourlyWageInfoValidator | ||
{ | ||
public HourlyWageInfoValidator(IPrevailingWageSurveyInfoValidator prevailingWageSurveyInfoValidator, IAlternateWageDataValidator alternateWageDataValidator) | ||
:base(prevailingWageSurveyInfoValidator, alternateWageDataValidator) | ||
{ | ||
RuleFor(h => h.WorkMeasurementFrequency).NotEmpty(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DOL.WHD.Section14c.Domain.Models; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public interface IAddressValidator : IValidator<Address> | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
DOL.WHD.Section14c.Business/Validators/IAlternateWageDataValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public interface IAlternateWageDataValidator : IValidator<AlternateWageData> | ||
{ | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
DOL.WHD.Section14c.Business/Validators/IApplicationSubmissionValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public interface IApplicationSubmissionValidator : IValidator<ApplicationSubmission> | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public interface IEmployeeValidator : IValidator<Employee> | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using DOL.WHD.Section14c.Domain.Models.Submission; | ||
using FluentValidation; | ||
|
||
namespace DOL.WHD.Section14c.Business.Validators | ||
{ | ||
public interface IEmployerValidator : IValidator<EmployerInfo> | ||
{ | ||
} | ||
} |
Oops, something went wrong.