Search Results for

    Show / Hide Table of Contents

    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
    Namespace: McMaster.Extensions.CommandLineUtils
    Assembly: McMaster.Extensions.CommandLineUtils.dll
    Syntax
    [AttributeUsage(AttributeTargets.Property)]
    public sealed class AllowedValuesAttribute : ValidationAttribute

    Constructors

    | Improve this Doc View Source

    AllowedValuesAttribute(String[])

    Initializes an instance of AllowedValuesAttribute.

    Declaration
    public AllowedValuesAttribute(params string[] allowedValues)
    Parameters
    Type Name Description
    System.String[] allowedValues
    | Improve this Doc View Source

    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 Source

    Comparer

    The comparison method used.

    Declaration
    public StringComparison Comparer { get; set; }
    Property Value
    Type Description
    System.StringComparison
    | Improve this Doc View Source

    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 Source

    IsValid(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)
    • Improve this Doc
    • View Source
    In This Article
    Back to top