ValidateCountAttribute Class

Defines an attribute that uses maximum and minimum limits to validate the number of arguments that a cmdlet parameter accepts. (This attribute can also be used by Windows PowerShell functions.) This class cannot be inherited.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

'Usage
Dim instance As ValidateCountAttribute

'Declaration
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field)> _
Public NotInheritable Class ValidateCountAttribute
	Inherits ValidateArgumentsAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) */ 
public final class ValidateCountAttribute extends ValidateArgumentsAttribute
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) 
public final class ValidateCountAttribute extends ValidateArgumentsAttribute

The following code example shows how this attribute can be declared:

[ValidateCount(1, 3)]
[Parameter(Position = 0, Mandatory = true)]
public string[] UserNames
{
  get { return userNames; }
  set { userNames = value; }
}

private string[] userNames;

There are no established scenarios for explicitly creating a ValidateCountAttribute object from within a cmdlet. The ValidateCountAttribute object is created and used indirectly when the attribute is declared.

The cmdlet declares this attribute when implementing a cmdlet parameter. For more information about the syntax and parameters that are used when declaring this, see ValidateCount Attribute Declaration.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

 

Target Platforms

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft