System.Management.Automatio ...


ValidateRangeAttribute Class
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.)


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in system.management.automation.dll)
Usage

Dim instance As ValidateRangeAttribute
Syntax

Visual Basic
<AttributeUsageAttribute(AttributeTargets.Property Or AttributeTargets.Field)> _
Public NotInheritable Class ValidateRangeAttribute
    Inherits ValidateEnumeratedArgumentsAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)] 
public sealed class ValidateRangeAttribute : ValidateEnumeratedArgumentsAttribute
C++
[AttributeUsageAttribute(AttributeTargets::Property|AttributeTargets::Field)] 
public ref class ValidateRangeAttribute sealed : public ValidateEnumeratedArgumentsAttribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) */ 
public final class ValidateRangeAttribute extends ValidateEnumeratedArgumentsAttribute
JScript
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) 
public final class ValidateRangeAttribute extends ValidateEnumeratedArgumentsAttribute
Example

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

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

private int inputData;
Remarks

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.


Inheritance Hierarchy

System.Object
   System.Attribute
     System.Management.Automation.Internal.CmdletMetadataAttribute
       System.Management.Automation.ValidateArgumentsAttribute
         System.Management.Automation.ValidateEnumeratedArgumentsAttribute
          System.Management.Automation.ValidateRangeAttribute
Thread Safety

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

Development Platforms

Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP, Windows 7, Windows 2008 R2

Target Platforms

Windows Server 2008, Windows Server 2003, Windows Vista, Windows XP, Windows 7, Windows 2008 R2
See Also

Page view tracker