ValidateLength Attribute Declaration
The ValidateLength attribute specifies the minimum and maximum number of characters for a cmdlet parameter argument. This attribute can also be used by Windows PowerShell functions.
Syntax
[ValidateLength(int minLength, int maxlength)]
Parameters
MinLength
(System.Int32)
Required. Specifies the minimum number of characters allowed.
MaxLength
(System.Int32)
Required. Specifies the maximum number of characters allowed.
Remarks
For more information about how to declare this attribute, see How to Declare Input Validation Rules.
When this attribute is not used, the corresponding parameter argument can be of any length.
The Windows PowerShell runtime throws an error under the following conditions:
When the value of the
MaxLength
attribute parameter is less than the value of theMinLength
attribute parameter.When the
MaxLength
attribute parameter is set to 0.When the argument is not a string.
The ValidateLength attribute is defined by the System.Management.Automation.Validatelengthattribute class.
See Also
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應