Class AllowedValuesAttribute
Specifies a set of allowed values and a comparer used to determine if a value is in that set.
By default, value comparison is case-sensitive. To ensure case matches exactly, set IgnoreCase to false.
Inheritance
System.Object
    System.Attribute
    System.ComponentModel.DataAnnotations.ValidationAttribute
    AllowedValuesAttribute
  Inherited Members
      System.ComponentModel.DataAnnotations.ValidationAttribute.FormatErrorMessage(System.String)
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(System.Object)
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.Validate(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.Validate(System.Object, System.String)
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessage
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceName
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageResourceType
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.ErrorMessageString
    
    
      System.ComponentModel.DataAnnotations.ValidationAttribute.RequiresValidationContext
    
    
      System.Attribute.Equals(System.Object)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
    
    
      System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Module)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
    
    
      System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    
    
      System.Attribute.GetHashCode()
    
    
      System.Attribute.IsDefaultAttribute()
    
    
      System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
    
    
      System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
    
    
      System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
    
    
      System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
    
    
      System.Attribute.IsDefined(System.Reflection.Module, System.Type)
    
    
      System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
    
    
      System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
    
    
      System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    
    
      System.Attribute.Match(System.Object)
    
    
      System.Attribute.TypeId
    
    
      System.Object.Equals(System.Object, System.Object)
    
    
      System.Object.GetType()
    
    
      System.Object.MemberwiseClone()
    
    
      System.Object.ReferenceEquals(System.Object, System.Object)
    
    
      System.Object.ToString()
    
  Namespace: McMaster.Extensions.CommandLineUtils
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
[AttributeUsage(AttributeTargets.Property)]
public sealed class AllowedValuesAttribute : ValidationAttribute
  Constructors
| Improve this Doc View SourceAllowedValuesAttribute(String[])
Initializes an instance of AllowedValuesAttribute.
Declaration
public AllowedValuesAttribute(params string[] allowedValues)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String[] | allowedValues | 
AllowedValuesAttribute(StringComparison, String[])
Initializes an instance of AllowedValuesAttribute.
Declaration
public AllowedValuesAttribute(StringComparison comparer, params string[] allowedValues)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.StringComparison | comparer | |
| System.String[] | allowedValues | 
Properties
| Improve this Doc View SourceComparer
The comparison method used.
Declaration
public StringComparison Comparer { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.StringComparison | 
IgnoreCase
Comparison between values and allowed values should ignore case.
Declaration
public bool IgnoreCase { get; set; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
Methods
| Improve this Doc View SourceIsValid(Object, ValidationContext)
Declaration
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | value | |
| System.ComponentModel.DataAnnotations.ValidationContext | validationContext | 
Returns
| Type | Description | 
|---|---|
| System.ComponentModel.DataAnnotations.ValidationResult | 
Overrides
System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(System.Object, System.ComponentModel.DataAnnotations.ValidationContext)