Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ValidateEnumeratedArgumentsAttribute Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Serves as a base class for validation attributes that validate each element of an argument of a parameter.

Namespace:   System.Management.Automation
Assembly:  System.Management.Automation (in System.Management.Automation.dll)

System.Object
  System.Attribute
    System.Management.Automation.Internal.CmdletMetadataAttribute
      System.Management.Automation.ValidateArgumentsAttribute
        System.Management.Automation.ValidateEnumeratedArgumentsAttribute
          System.Management.Automation.ValidateLengthAttribute
          System.Management.Automation.ValidatePatternAttribute
          System.Management.Automation.ValidateRangeAttribute
          System.Management.Automation.ValidateScriptAttribute
          System.Management.Automation.ValidateSetAttribute

[AttributeUsageAttribute(AttributeTargets.Property | AttributeTargets.Field)]
public abstract class ValidateEnumeratedArgumentsAttribute : ValidateArgumentsAttribute

NameDescription
System_CAPS_protmethodValidateEnumeratedArgumentsAttribute()

Initializes a new instance of the ValidateEnumeratedArgumentsAttribute class.

NameDescription
System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Attribute.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object)

(Inherited from Attribute.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_protmethodValidate(Object, EngineIntrinsics)

Validates the specified enumerated arguments by calling ValidateArgumentsAttribute.Validate(Object, EngineIntrinsics) for each argument.(Overrides ValidateArgumentsAttribute.Validate(Object, EngineIntrinsics).)

System_CAPS_protmethodValidateElement(Object)

When overridden in a derived class, validates a specified argument value of an enumerated argument.

Validation attributes can be attached to cmdlet parameters to ensure that the cmdlet is not invoked with values that are not valid for its parameters. Existing validation attribute classes that derive from this class are listed in the Inheritance Hierarchy section of this topic.

Attribute classes that derive from the ValidateEnumeratedArgumentsAttribute class unroll enumerations and then validate each element individually. Attributes that derive from ValidateArgumentsAttribute validate the argument as a whole.

When this attribute is applied to a string parameter, the string command argument is validated. When this attribute is applied to a string array parameter, the string array command argument is validated.

To create custom argument validation attributes, derive from the ValidateEnumeratedArgumentsAttribute class and override the following methods.

ValidateEnumeratedArgumentsAttribute.Validate(Object, EngineIntrinsics)

This method must be overridden before the attribute can be used to validate the argument value.

ToString

It is recommended to override ToString to return a readable string similar to the attribute declaration, for example: [ValidateRangeAttribute(5,10)].

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: