---
title: TaskValidator&lt;TTask&gt;
summary: API reference for TaskValidator<TTask>.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-24
library: SAIF.Services
reference_type: package
---

# TaskValidator&lt;TTask&gt;

A generic FluentValidation `AbstractValidator<TTask>` (constrained to `TaskBase`) enforcing that any task's due date is set and falls on a valid working day, and that its text is present and no longer than 4000 characters. It depends on `IWorkCalendarService` to determine whether a candidate task date is a working day.

## Purpose
- Rejects tasks with an unset (`DateTime.MinValue`) due date.
- Rejects tasks whose due date is not a valid working day, per `IWorkCalendarService.IsWorkingDay`.
- Rejects tasks with null/empty text or text exceeding 4000 characters.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| TaskValidator(...) | `public TaskValidator(IWorkCalendarService workCalendarService)` | Registers FluentValidation rules for `TaskDate` (required, must be a working day) and `TaskText` (required, max 4000 characters) against the injected work-calendar service. |

## Behavioral notes
- Both validation rules produce fixed, human-readable error messages ("Error: Due date is required.", "Error: Due date must be a valid work day.", "Error: Text is required.", "Error: Text cannot be more than 4000 characters.") rather than localizable resource strings.
- The 4000-character text limit matches the truncation limit used elsewhere (e.g. `PolicyDocumentsBatchService.MaxTaskTextLength`), suggesting a shared platform constraint on task text length*.

> **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/Tasks/TaskValidator.cs
