ValidateEnumeratedArgumentsAttribute Class

Definition

A variant of ValidateArgumentsAttribute which unrolls enumeration values and validates each element individually.

public ref class ValidateEnumeratedArgumentsAttribute abstract : System::Management::Automation::ValidateArgumentsAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property)]
public abstract class ValidateEnumeratedArgumentsAttribute : System.Management.Automation.ValidateArgumentsAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property)>]
type ValidateEnumeratedArgumentsAttribute = class
    inherit ValidateArgumentsAttribute
Public MustInherit Class ValidateEnumeratedArgumentsAttribute
Inherits ValidateArgumentsAttribute
Inheritance
ValidateEnumeratedArgumentsAttribute
Derived
Attributes

Remarks

ValidateEnumeratedArgumentsAttribute is like ValidateArgumentsAttribute, except that if the argument value is enumerable, ValidateEnumeratedArgumentsAttribute will unroll the enumeration and validate each item individually. Existing enumerated validation attributes include ValidateLengthAttribute, ValidateRangeAttribute, ValidatePatternAttribute, and ValidateSetAttribute. PSSnapins wishing to create custom enumerated argument validation attributes should derive from and override the abstract method, after which they can apply the attribute to their parameters. It is also recommended to override ToString() to return a readable string similar to the attribute declaration, for example "[ValidateRangeAttribute(5,10)]". If this attribute is applied to a string parameter, the string command argument will be validated. If this attribute is applied to a string[] parameter, each string command argument will be validated.

Constructors

ValidateEnumeratedArgumentsAttribute()

Initializes a new instance of a class derived from ValidateEnumeratedArgumentsAttribute.

Methods

Validate(Object, EngineIntrinsics)

Calls ValidateElement in each element in the enumeration argument value.

ValidateElement(Object)

Abstract method to be overridden by subclasses, implementing the validation of each parameter argument.

Applies to

See also