NoteModifyRequestValidator¶
Validates a NoteModifyRequest used to create or update a bill/claim note: it requires note text (bounded to 600 characters), a type and category code, and — depending on the note's category — cross-checks that the request carries a valid BillId (for bill-category notes, via IBillQueryProvider.BillExists) or a valid ClaimId (for claim-category notes, via IClaimQueryProvider.IsValidClaim). It also verifies the type code is valid for the selected category and, for existing notes (Id > 0), that the note id resolves to an existing audit note and that the supplied UpdateNumber matches the current version to guard against concurrent-edit contention.
Purpose¶
- Requires
NoteTextto be non-empty and at most 600 characters. - Requires
NoteTypeCodeandNoteCategoryCodeto be non-null. - Validates
BillIdpresence and existence (viaIBillQueryProvider.BillExists) only whenNoteCategoryCode == "B"; otherwise treats the bill-id check as satisfied. - Validates
ClaimIdpresence and validity (viaIClaimQueryProvider.IsValidClaim) only whenNoteCategoryCode == "C"; otherwise treats the claim-id check as satisfied. - When
NoteTypeCodeis set, requires it to be a valid type code for the selected category viaIBillQueryProvider.AuditQueries.NoteQueries.GetNoteTypeCode. - When updating an existing note (
Id > 0), requires the id to resolve to an existing audit note. - Requires
UpdateNumberto match the current stored version viaIBillQueryProvider.AuditNoteQueries.IsAuditNoteNoContention, preventing lost-update conflicts.
Context¶
- Namespace:
SAIF.Services.Claims.Bills.Validators - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| NoteModifyRequestValidator | NoteModifyRequestValidator(IBillQueryProvider provider, IClaimQueryProvider claimQueryProvider) |
Wires text length/required rules plus category-conditional bill/claim existence checks, a type-code-per-category check, an existing-note lookup, and an optimistic-concurrency (UpdateNumber) check.* |
Behavioral notes¶
- Validation is enforced via FluentValidation's
AbstractValidator<T>base.* - The
BillIdandClaimIdexistence rules are cross-field checks that branch onNoteCategoryCode: a bill-category note ("B") requires a validBillId, a claim-category note ("C") requires a validClaimId, and either check is skipped (returns true) when the category does not match.* - The type-code-per-category check only executes inside a
When(request => request.NoteTypeCode != null, ...)guard.* - The existing-note lookup only executes inside a
When(request => request.Id > 0, ...)guard, so new notes (id not yet assigned) skip it.* - The
UpdateNumberrule enforces optimistic concurrency: it fails when another user has updated the note since the client last read it, viaIBillQueryProvider.AuditNoteQueries.IsAuditNoteNoContention.*
Constraints and usage notes¶
- Requires both
IBillQueryProviderandIClaimQueryProviderimplementations to be supplied via constructor injection.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
- Services/SAIF.Services/Claims/Bills/Validators/NoteModifyRequestValidator.cs