Class FluentCommandSettingsValidator<TSettings>
- Namespace
- Ploch.CommandLine.Spectre.FluentValidation
- Assembly
- Ploch.CommandLine.Spectre.FluentValidation.dll
A command settings validator that uses FluentValidation to validate command settings.
public class FluentCommandSettingsValidator<TSettings> : ICommandSettingsValidator<TSettings> where TSettings : CommandSettings
Type Parameters
TSettingsThe type of command settings to validate.
- Inheritance
-
FluentCommandSettingsValidator<TSettings>
- Implements
-
ICommandSettingsValidator<TSettings>
- Inherited Members
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.
Constructors
- FluentCommandSettingsValidator(IServiceScopeFactory)
A command settings validator that uses FluentValidation to validate command settings.
Methods
- Validate(CommandContext, TSettings)
Validates the command settings using FluentValidation.