Skip to content

Commit e916719

Browse files
author
James Brundage
committed
Allowing ValidateTypes transpiler to apply to an [VariableExpressionAST] (#66)
1 parent 14a3bf9 commit e916719

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Transpilers/Parameters/ValidateTypes.psx.ps1

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ param(
4242
# TypeNames will be treated first as real types, then as exact matches, then as wildcards, and then as regular expressions.
4343
[Parameter(Mandatory,Position=0)]
4444
[string[]]
45-
$TypeName
45+
$TypeName,
46+
47+
# The variable that will be validated.
48+
[Parameter(ValueFromPipeline,ParameterSetName='VariableExpressionAST')]
49+
[Management.Automation.Language.VariableExpressionAST]
50+
$VariableAST
4651
)
4752

4853

@@ -92,6 +97,12 @@ if (-not `$isTypeOk) {
9297
}
9398
return `$true
9499
})]
95-
param()
100+
$(
101+
if ($psCmdlet.ParameterSetName -eq 'Parameter') {
102+
'param()'
103+
} else {
104+
'$' + $VariableAST.variablePath.ToString()
105+
}
106+
)
96107
"@)
97108
}

0 commit comments

Comments
 (0)