---
title: NoteModifyRequestValidator
summary: API reference for NoteModifyRequestValidator.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# 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 `NoteText` to be non-empty and at most 600 characters.
- Requires `NoteTypeCode` and `NoteCategoryCode` to be non-null.
- Validates `BillId` presence and existence (via `IBillQueryProvider.BillExists`) only when `NoteCategoryCode == "B"`; otherwise treats the bill-id check as satisfied.
- Validates `ClaimId` presence and validity (via `IClaimQueryProvider.IsValidClaim`) only when `NoteCategoryCode == "C"`; otherwise treats the claim-id check as satisfied.
- When `NoteTypeCode` is set, requires it to be a valid type code for the selected category via `IBillQueryProvider.AuditQueries.NoteQueries.GetNoteTypeCode`.
- When updating an existing note (`Id > 0`), requires the id to resolve to an existing audit note.
- Requires `UpdateNumber` to match the current stored version via `IBillQueryProvider.AuditNoteQueries.IsAuditNoteNoContention`, preventing lost-update conflicts.

## Context
- Namespace: `SAIF.Services.Claims.Bills.Validators`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet 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 `BillId` and `ClaimId` existence rules are cross-field checks that branch on `NoteCategoryCode`: a bill-category note (`"B"`) requires a valid `BillId`, a claim-category note (`"C"`) requires a valid `ClaimId`, 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 `UpdateNumber` rule enforces optimistic concurrency: it fails when another user has updated the note since the client last read it, via `IBillQueryProvider.AuditNoteQueries.IsAuditNoteNoContention`.*

## Constraints and usage notes
- Requires both `IBillQueryProvider` and `IClaimQueryProvider` implementations 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
