Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)]

Parameters

MinRange (Object)
Required. Specifies the minimum value allowed.

MaxRange (Object)
Required. Specifies the maximum value allowed.

  • The Windows PowerShell runtime throws a construction error when the value of the MinRange parameter is greater than the value of the MaxRange parameter.

  • The Windows PowerShell runtime throws a validation error under the following conditions:

    • When the value of the argument is less than the MinRange limit or greater than the MaxRange limit.

    • When the argument is not of the same type as the MinRange and the MaxRange parameters.

  • The ValidateRange attribute is defined by the ValidateRangeAttribute class.



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.