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

# LegalNoteValidator

FluentValidation validator for `LegalNote`, enforcing required non-empty text within a 4000-character limit, that appended text (including a computed date/user header) does not push the combined text over 4000 characters, that the note's category passes the nested `LegalNoteCategoryValidator`, and that a case ID is specified.

## Purpose
- Requires note `Text` to be non-empty and no more than 4000 characters.
- Validates that appending `AppendText` (plus a computed date/user/static-character header) would not cause the combined note text to exceed 4000 characters.
- Delegates category validation to `LegalNoteCategoryValidator`, requiring a non-empty category code.
- Requires a non-zero `CaseId`.

## Context
- Namespace: `SAIF.Services.Legal.Notes.Validators`
- Assembly/package: `SAIF.Services` (packaged inside the `SAIF.SAIFCode.Core` NuGet package).

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| LegalNoteValidator (constructor) | `public LegalNoteValidator(IUserProfileService userProfileService)` | Stores the user-profile service (used to compute the current user's ID length for the append-text header calculation) and configures the FluentValidation rules for `Text`, `AppendText`, `Category`, and `CaseId`. |

## Behavioral notes
- `HasValidAppendTextLength` computes an estimated header length (date length + current user ID length + 18 static characters) and requires the combined length of existing text, append text, and header to stay at or under 4000 characters; a `null` append text is always considered valid (no append requested).
- The date-length component of the header calculation uses the note's existing `UpdateDate` when present, otherwise falls back to a fixed length constant (`DefaultUserLength`, reused here for the date-length default) rather than a true default date-format length.*

## Constraints and usage notes
- Carries a `CA1710:IdentifiersShouldHaveCorrectSuffix` suppression, since FluentValidation's naming convention ("Validator") does not match the `IValidator` interface-suffix rule.*
- Requires a constructed `IUserProfileService` to evaluate the `AppendText` length rule, coupling this validator to a resolvable current-user context rather than pure data rules.*

> **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/Legal/Notes/Validators/LegalNoteValidator.cs`
