Class AttributeValidator
A validator that uses a System.ComponentModel.DataAnnotations.ValidationAttribute to validate a command, command line option, or argument.
Inheritance
System.Object
    AttributeValidator
  Namespace: McMaster.Extensions.CommandLineUtils.Validation
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public class AttributeValidator : IValidator, IOptionValidator, IArgumentValidator, ICommandValidatorConstructors
| Improve this Doc View SourceAttributeValidator(ValidationAttribute)
Initializes an instance of AttributeValidator.
Declaration
public AttributeValidator(ValidationAttribute attribute)Parameters
| Type | Name | Description | 
|---|---|---|
| System.ComponentModel.DataAnnotations.ValidationAttribute | attribute | 
Methods
| Improve this Doc View SourceGetValidationResult(CommandArgument, ValidationContext)
Gets the validation result for a command line argument.
Declaration
public ValidationResult GetValidationResult(CommandArgument argument, ValidationContext context)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandArgument | argument | |
| System.ComponentModel.DataAnnotations.ValidationContext | context | 
Returns
| Type | Description | 
|---|---|
| System.ComponentModel.DataAnnotations.ValidationResult | 
GetValidationResult(CommandLineApplication, ValidationContext)
Checks whether the command is valid using any associated validation attributes.
Declaration
public ValidationResult GetValidationResult(CommandLineApplication command, ValidationContext context)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandLineApplication | command | The command line application to validate | 
| System.ComponentModel.DataAnnotations.ValidationContext | context | The context under which validation should be performed | 
Returns
| Type | Description | 
|---|---|
| System.ComponentModel.DataAnnotations.ValidationResult | 
GetValidationResult(CommandOption, ValidationContext)
Gets the validation result for a command line option.
Declaration
public ValidationResult GetValidationResult(CommandOption option, ValidationContext context)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandOption | option | |
| System.ComponentModel.DataAnnotations.ValidationContext | context | 
Returns
| Type | Description | 
|---|---|
| System.ComponentModel.DataAnnotations.ValidationResult |