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

# CollectionTaskValidator

A FluentValidation validator for `CollectionTask` that extends the shared `TaskValidator<CollectionTask>` base (from `SAIF.Services.Tasks`) with Collections-specific rules: it confirms the task's context number refers to an existing case (via `ICollectionsService.GetCaseById`) and constrains the task due date to between today and one year in the future. It depends on `ICollectionsService` to perform the case-existence check and on `IWorkCalendarService` (passed through to the base validator).

## Purpose
- Requires that a task's `ContextNumber` corresponds to a real, resolvable case.
- Constrains a task's due date (`TaskDate`) to fall between today and one year from today.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| CollectionTaskValidator(...) | `public CollectionTaskValidator(ICollectionsService service, IWorkCalendarService workCalendarService)` | Wires in the Collections service used for case-existence checks, passes the work-calendar service to the base `TaskValidator<CollectionTask>`, and registers the context-number and due-date rules described above. |

## Behavioral notes
- The case-existence check (`IsValidCase`) only performs the lookup when `ContextNumber` has a value; a null context number is treated as invalid rather than skipped*.
- Inherits its remaining validation behavior from `TaskValidator<CollectionTask>` (declared in `SAIF.Services.Tasks`), which is not documented on this page because it is not a base class from a separately documented dependency library.

## Sources
- Services/SAIF.Services/Collections/Validators/CollectionTaskValidator.cs
