ValidateScriptAttribute Class

Definition

Class for validating against a script block.

public ref class ValidateScriptAttribute sealed : System::Management::Automation::ValidateEnumeratedArgumentsAttribute
public sealed class ValidateScriptAttribute : System.Management.Automation.ValidateEnumeratedArgumentsAttribute
type ValidateScriptAttribute = class
    inherit ValidateEnumeratedArgumentsAttribute
Public NotInheritable Class ValidateScriptAttribute
Inherits ValidateEnumeratedArgumentsAttribute
Inheritance

Constructors

ValidateScriptAttribute(ScriptBlock)

Initializes a new instance of the ValidateScriptAttribute class.

Properties

ErrorMessage

Gets or sets the custom error message that is displayed to the user. The item being validated and the validating scriptblock is passed as the first and second formatting argument.

[ValidateScript("$_ % 2", ErrorMessage = "The item '{0}' did not pass validation of script '{1}'")]
ScriptBlock

Gets the scriptblock to be used in the validation.

Methods

Validate(Object, EngineIntrinsics)

Calls ValidateElement in each element in the enumeration argument value.

(Inherited from ValidateEnumeratedArgumentsAttribute)
ValidateElement(Object)

Abstract method to be overridden by subclasses, implementing the validation of each parameter argument.

(Inherited from ValidateEnumeratedArgumentsAttribute)

Applies to