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 Constructor (Object, Object)


Updated: April 27, 2016

Applies To: Windows PowerShell

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

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

public ValidateRangeAttribute(
	object minRange,
	object maxRange


Type: System.Object

The minimum value allowed for the cmdlet parameter argument.

Type: System.Object

The maximum value allowed for the cmdlet parameter argument.

Exception Condition

minRange or maxRange has an argument that is not valid.


minRange and maxRange are of different types.


maxRange is less than minRange.


minRange and maxRange are not IComparable.

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;

Return to top

Community Additions