| description | ValidateRange Attribute Declaration |
|---|---|
| ms.date | 09/13/2016 |
| title | ValidateRange Attribute Declaration |
The ValidateRange attribute specifies the minimum and maximum values (the range) for the cmdlet parameter argument. This attribute can also be used by Windows PowerShell functions.
[ValidateRange(object minRange, object maxRange)]MinRange (System.Object)
Required. Specifies the minimum value allowed.
MaxRange (System.Object)
Required. Specifies the maximum value allowed.
-
The Windows PowerShell runtime throws a construction error when the value of the
MinRangeparameter is greater than the value of theMaxRangeparameter. -
The Windows PowerShell runtime throws a validation error under the following conditions:
-
When the value of the argument is less than the
MinRangelimit or greater than theMaxRangelimit. -
When the argument is not of the same type as the
MinRangeand theMaxRangeparameters.
-
-
The ValidateRange attribute is defined by the System.Management.Automation.ValidateRangeAttribute class.