Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ValidateRangeAttribute Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Defines an attribute that uses minimum and maximum values to validate a cmdlet parameter argument. (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)


<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field)>
Public NotInheritable Class ValidateRangeAttribute
	Inherits ValidateEnumeratedArgumentsAttribute

NameDescription
System_CAPS_pubmethodValidateRangeAttribute(Object, Object)

Initializes a new instance of the ValidateRangeAttribute class with the minimum and maximum values allowed for the cmdlet parameter argument.

NameDescription
System_CAPS_pubpropertyMaxRange

Gets the maximum value allowed for the cmdlet parameter argument.

System_CAPS_pubpropertyMinRange

Gets the minimum value allowed for the cmdlet parameter argument.

System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object)

(Inherited from Attribute.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

There are no established scenarios for explicitly creating a ValidateRangeAttribute object from within a cmdlet. The ValidateRangeAttribute 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 used to declare this attribute within a cmdlet, see ValidateRange Attribute Declaration.

This example specifies a range of 0 to 5 for the InputData parameter.

[ValidateRange(0, 5)]
[Parameter(Position = 0, Mandatory = true)]
public int InputData
{
  get { return inputData; }
  set { inputData = value; }
}

private int inputData;

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

Return to top
Show: