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

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.

[ValidateLength(int minLength, int maxlength)]

Parameters

MinLength (Integer)
Required. Specifies the minimum number of characters allowed.

MaxLength (Integer)
Required. Specifies the maximum number of characters allowed.

  • 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 the MinLength 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 ValidateLengthAttribute class.



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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.