ValidateSetAttribute Class
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Defines an attribute that uses a set of values to validate a cmdlet parameter argument.
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation)
Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation)
[AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field)] public sealed class ValidateSetAttribute : ValidateEnumeratedArgumentsAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field) */ public final class ValidateSetAttribute extends ValidateEnumeratedArgumentsAttribute
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."); } }
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 ValidateSetAttribute Declaration.
System.Object
System.Attribute
System.Management.Automation.Internal.CmdletMetadataAttribute
System.Management.Automation.ValidateArgumentsAttribute
System.Management.Automation.ValidateEnumeratedArgumentsAttribute
System.Management.Automation.ValidateSetAttribute
System.Attribute
System.Management.Automation.Internal.CmdletMetadataAttribute
System.Management.Automation.ValidateArgumentsAttribute
System.Management.Automation.ValidateEnumeratedArgumentsAttribute
System.Management.Automation.ValidateSetAttribute
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 PreviewSend comments about this topic to Microsoft.