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.
Syntax
[ValidateRange(object minRange, object maxRange)]
Parameters
MinRange
(System.Object)
Required. Specifies the minimum value allowed.
MaxRange
(System.Object)
Required. Specifies the maximum value allowed.
Remarks
The Windows PowerShell runtime throws a construction error when the value of the
MinRange
parameter is greater than the value of theMaxRange
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 theMaxRange
limit.When the argument is not of the same type as the
MinRange
and theMaxRange
parameters.
The ValidateRange attribute is defined by the System.Management.Automation.Validaterangeattribute class.
See Also
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應