Skip to content

Commit bbb3baa

Browse files
committed
ECER-5291: Validation Engine for ICRA eligibility object added
1 parent 0dd8384 commit bbb3baa

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

src/ECER.Engines.Validation/Configurer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
22
using ECER.Engines.Validation.Applications;
3+
using ECER.Engines.Validation.ICRA;
34
using ECER.Infrastructure.Common;
45
using Microsoft.Extensions.DependencyInjection;
56

@@ -17,5 +18,8 @@ public void Configure([NotNull] ConfigurationContext configurationContext)
1718
{
1819
return provider.GetRequiredService<NewApplicationSubmissionValidationEngine>();
1920
});
21+
22+
// ICRA
23+
configurationContext.Services.AddTransient<IICRAValidationEngine, IcraEligibilitySubmissionValidationEngine>();
2024
}
2125
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using ECER.Managers.Registry.Contract.ICRA;
2+
3+
namespace ECER.Engines.Validation.ICRA;
4+
5+
public interface IICRAValidationEngine
6+
{
7+
Task<Applications.ValidationResults> Validate(ICRAEligibility eligibility);
8+
}
9+
10+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using ECER.Managers.Registry.Contract.ICRA;
2+
3+
namespace ECER.Engines.Validation.ICRA;
4+
5+
internal sealed class IcraEligibilitySubmissionValidationEngine : IICRAValidationEngine
6+
{
7+
public async Task<Applications.ValidationResults> Validate(ICRAEligibility eligibility)
8+
{
9+
await Task.CompletedTask;
10+
11+
var errors = new List<string>();
12+
13+
// Minimal draft submission rules: must have ApplicantId and Draft status
14+
if (string.IsNullOrWhiteSpace(eligibility.ApplicantId))
15+
{
16+
errors.Add("ApplicantId is required");
17+
}
18+
if (!eligibility.InternationalCertifications.Any(d=>d.CertificateStatus==CertificateStatus.Valid))
19+
{
20+
errors.Add("Valid International certification is missing");
21+
}
22+
23+
24+
// If any InternationalCertification exists, ensure minimally required fields
25+
if (eligibility.InternationalCertifications != null)
26+
{
27+
foreach (var ic in eligibility.InternationalCertifications)
28+
{
29+
if (string.IsNullOrWhiteSpace(ic.CertificateTitle))
30+
{
31+
errors.Add("International certification missing CertificateTitle");
32+
}
33+
}
34+
}
35+
36+
if (!eligibility.EmploymentReferences.Any())
37+
{
38+
errors.Add("Employment Reference is missing");
39+
}
40+
41+
// If any EmploymentReferences exist, ensure minimally required fields
42+
if (eligibility.EmploymentReferences != null)
43+
{
44+
foreach (var r in eligibility.EmploymentReferences)
45+
{
46+
if (string.IsNullOrWhiteSpace(r.FirstName) || string.IsNullOrWhiteSpace(r.LastName) || string.IsNullOrWhiteSpace(r.EmailAddress))
47+
{
48+
errors.Add("Employment reference requires FirstName, LastName, and EmailAddress");
49+
}
50+
}
51+
}
52+
53+
return new Applications.ValidationResults(errors);
54+
}
55+
}
56+
57+

0 commit comments

Comments
 (0)