ValidateEnumeratedArgumentsAttribute Class

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)

'Usage
Dim instance As ValidateEnumeratedArgumentsAttribute

[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)] 
public abstract class ValidateEnumeratedArgumentsAttribute : ValidateArgumentsAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) */ 
public abstract class ValidateEnumeratedArgumentsAttribute extends ValidateArgumentsAttribute
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) 
public abstract class ValidateEnumeratedArgumentsAttribute extends ValidateArgumentsAttribute

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

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.

 

Target Platforms

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft