Collapse the table of content
Expand the table of content
Expand Minimize
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.

ValidateSetAttribute Constructor

Creates a new ValidateSetAttribute object.

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

Dim validValues As String()

Dim instance As New ValidateSetAttribute(validValues)

public ValidateSetAttribute (
	params string[] validValues
public ValidateSetAttribute (
	String[] validValues
public function ValidateSetAttribute (
	... validValues : String[]



The set of the valid values for the cmdlet parameter argument.

The following lines of code show how this attribute may be declared.

[Cmdlet(VerbsDiagnostic.Test, "ArgumentSet")]
public class TestArgumentSetCommand : Cmdlet
  [ValidateSet("Steve", "Mary", "Carl", IgnoreCase = true)]
  [Parameter(Position = 0, Mandatory = true)]
  public string UserName
    get { return userName; }
    set { userName = value; }

  private string userName;

  // Override input processing method. 
  protected override void ProcessRecord()
    WriteObject(userName + " is a valid input.");

Exception typeCondition

The validValues parameter contains arguments that are not valid.

There are no established scenarios for explicitly creating a ValidateSetAttribute object from within a cmdlet. The ValidateSetAttribute object is created and used indirectly when the attribute is declared.

This attribute is declared when implementing a cmdlet parameter. For more information about the syntax used to declare this attribute, see ValidateSet Attribute Declaration.


Target Platforms

© 2015 Microsoft