ValidateEnumeratedArgumentsAttribute Class
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation)
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)] public abstract class ValidateEnumeratedArgumentsAttribute : ValidateArgumentsAttribute
/** @attribute 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[] parameter, the string[] command argument is validated.
To create custom argument validation attributes, derive from the ValidateEnumeratedArgumentsAttribute class and override the following methods.
ValidateThis method must be overridden before the attribute can be used to validate the argument value.
ToStringIt is recommended to override ToString to return a readable string similar to the attribute declaration, for example "[ValidateRangeAttribute(5,10)]".
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
Target Platforms
Windows Developer Preview, Windows Server Developer PreviewSend comments about this topic to Microsoft.