Constructor FluentCommandSettingsValidator
- Namespace
- Ploch.CommandLine.Spectre.FluentValidation
- Assembly
- Ploch.CommandLine.Spectre.FluentValidation.dll
FluentCommandSettingsValidator(IServiceScopeFactory)
A command settings validator that uses FluentValidation to validate command settings.
public FluentCommandSettingsValidator(IServiceScopeFactory scopeFactory)
Parameters
scopeFactoryIServiceScopeFactoryFactory used to create a scope per validation, from which the FluentValidation validator is resolved.
Remarks
The validator is resolved per call rather than injected. This type is registered as a singleton, and Spectre resolves commands from the root provider, so a scoped dependency must be resolved inside an explicit scope: resolved from the root, it either fails scope validation or is promoted to the host's lifetime. FluentValidation registers validators as scoped by default, and a validator may legitimately depend on a DbContext, a repository, or a scoped user context. Resolving inside a scope keeps the wrapper a singleton while letting consumer validators keep any lifetime and any dependencies.