SecurityOverrideValidator¶
A FluentValidation AbstractValidator<SecurityOverrideEdit> that enforces the business rules a security-override edit must satisfy before SecurityOverrideService persists it. It depends on ISecurityOverrideService for claim/user existence checks and on IWorkCalendarService to confirm the effective date falls on a working day.
Purpose¶
- Rejects a security-override edit whose claim number does not resolve to an existing injury claim (via
service.IsValidClaim). - Rejects an edit whose user ID does not resolve to a valid application user (via
service.IsValidUserId). - Constrains the effective date to today through one month in the future, but only when the effective date has actually changed from its previous value.
- Requires the effective date to be a valid working day per
IWorkCalendarService.IsWorkingDay. - Requires the expiration date to be on or after the effective date.
Context¶
- Namespace:
SAIF.Services.Claims.SecurityOverride - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| SecurityOverrideValidator | public SecurityOverrideValidator(ISecurityOverrideService service, IWorkCalendarService workCalendarService) |
Registers the rule set: claim-number existence, user-ID existence, effective-date range/working-day checks, and expiration-after-effective-date check, each with a user-facing error message. |
Behavioral notes¶
- The effective-date range rule (
InclusiveBetween(Today, Today.AddMonths(1))) is conditioned with.When(x => x.EffDate != x.PreviousEffDate), so it only fires when the effective date is being changed. - The expiration-date rule delegates to the private
IsValidExpDatepredicate, which simply checksexpDate >= EffDate. - All rules produce claim-specific
"Error: ..."messages surfaced back through the validation result consumed bySecurityOverrideService.ValidateAndAddErrors.
Sources¶
- Services/SAIF.Services/Claims/SecurityOverride/SecurityOverrideValidator.cs