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.

ValidatePatternAttribute Class

 

Updated: April 27, 2016

Applies To: Windows PowerShell

Defines an attribute that uses a regular expression to validate the character pattern of 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)


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

NameDescription
System_CAPS_pubmethodValidatePatternAttribute(String)

Creates a new instance of the ValidatePatternAttribute class with a regular expression for validating the cmdlet parameter argument.

NameDescription
System_CAPS_pubpropertyOptions

Gets and sets the regular expression options that are used to further define the attribute pattern.

System_CAPS_pubpropertyRegexPattern

Gets the Regex pattern that is used in the validation.

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 ValidatePatternAttribute object from within a cmdlet. The ValidatePatternAttribute 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 attribute within a cmdlet, see ValidatePattern Attribute Declaration.

The following code example specifies a pattern of four digits, with each digit having the value of 0-9.

[ValidatePattern("[0-9][0-9][0-9][0-9]")]
[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: