ValidatePatternAttribute Class

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)

'Usage
Dim instance As ValidatePatternAttribute

[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)] 
public sealed class ValidatePatternAttribute : ValidateEnumeratedArgumentsAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) */ 
public final class ValidatePatternAttribute extends ValidateEnumeratedArgumentsAttribute
AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) 
public final class ValidatePatternAttribute extends ValidateEnumeratedArgumentsAttribute

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;

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 ValidatePatternAttribute 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