feat: add validatepattern
This commit is contained in:
parent
d4341b3b40
commit
55d4504645
@ -120,7 +120,9 @@ foreach ($param in $paramBlock.Parameters) {
|
|||||||
} elseif ($attr.TypeName.Name -eq 'ValidateSet') {
|
} elseif ($attr.TypeName.Name -eq 'ValidateSet') {
|
||||||
$val.values = $attr.PositionalArguments.Value
|
$val.values = $attr.PositionalArguments.Value
|
||||||
} elseif ($attr.TypeName.Name -eq 'ValidateScript') {
|
} elseif ($attr.TypeName.Name -eq 'ValidateScript') {
|
||||||
$val.script = $attr.PositionalArguments.ScriptBlock.Extent.Text
|
$val.value = $attr.PositionalArguments.ScriptBlock.Extent.Text
|
||||||
|
} elseif ($attr.TypeName.Name -eq 'ValidatePattern') {
|
||||||
|
$val.value = $attr.PositionalArguments.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
$validations += [pscustomobject]$val
|
$validations += [pscustomobject]$val
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
# Accepts pipeline input by value
|
# Accepts pipeline input by value
|
||||||
[Parameter(ValueFromPipeline = $true, ParameterSetName = 'Set2')]
|
[Parameter(ValueFromPipeline = $true, ParameterSetName = 'Set2')]
|
||||||
|
[ValidatePattern("^[a-zA-Z0-9]*$")]
|
||||||
[string]$InputObject,
|
[string]$InputObject,
|
||||||
|
|
||||||
# Accepts pipeline input by property name
|
# Accepts pipeline input by property name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user