ValidateEnumeratedArgumentsAttribute
Class
Definition
A variant of ValidateArgumentsAttribute which unrolls enumeration values and validates each element individually.
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field)]
public abstract class ValidateEnumeratedArgumentsAttribute : System.Management.Automation.ValidateArgumentsAttribute
- Inheritance
- Derived
- Attributes
Remarks
ValidateEnumeratedArgumentsAttribute is like ValidateArgumentsAttribute, except that if the argument value is an enumeration, ValidateEnumeratedArgumentsAttribute will unroll the enumeration and validate each item individually.
Existing enumerated validation attributes include
<xref href="System.Management.Automation.ValidateLengthAttribute"></xref>,
<xref href="System.Management.Automation.ValidateRangeAttribute"></xref>,
<xref href="System.Management.Automation.ValidatePatternAttribute"></xref>, and
<xref href="System.Management.Automation.ValidateSetAttribute"></xref>.
PSSnapins wishing to create custom enumerated argument validation attributes
should derive from
<seealso cref="T:System.Management.Automation.ValidateEnumeratedArgumentsAttribute"></seealso>
and override the
<seealso cref="M:System.Management.Automation.ValidateEnumeratedArgumentsAttribute.ValidateElement(System.Object)"></seealso>
abstract method, after which they can apply the
attribute to their parameters.
It is also recommended to override
<xref href="System.Object.ToString"></xref> 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) |
Overridden by subclasses to implement the validation of each parameter argument |