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

# ValidatorFactory

Implements FluentValidation's `IValidatorFactory` on top of an Autofac `IComponentContext`, resolving `IValidator<T>` instances from the DI container by type rather than requiring callers to know the concrete validator implementation.

## Purpose
- Resolves the registered FluentValidation `IValidator` for a runtime `Type` or generic type parameter, delegating to the Autofac container.

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

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| ValidatorFactory(...) | `public ValidatorFactory(IComponentContext componentContext)` | Stores the Autofac component context used to resolve validators. |
| GetValidator(type) | `public IValidator GetValidator(Type type)` | Resolves and returns the `IValidator<type>` registered in the Autofac container for the given runtime `type`, as a non-generic `IValidator`. |
| GetValidator&lt;T&gt;() | `public IValidator<T> GetValidator<T>()` | Resolves and returns the `IValidator<T>` registered in the Autofac container for `T`. |

## Behavioral notes
- `GetValidator(Type)` builds the closed generic `IValidator<>` type at runtime via reflection (`MakeGenericType`) before resolving it from Autofac.

## Sources
- Services/SAIF.Services/Utilities/ValidatorFactory.cs
