- Added validation for empty values in Assert-ConfigurationDataParameter. - Introduced Assert-ConfigurationDataSecretReference for secret reference validation. - Implemented Test-ConfigurationDataExpressionParentheses to validate expression syntax. - Added Test-ConfigurationDataMissingReferenceError to check for missing parameter or variable definitions. - Updated Invoke-ConfigurationDataExpression to handle new validation logic. - Revised Readme.md to reflect changes in secret reference handling.
40 lines
782 B
PowerShell
40 lines
782 B
PowerShell
function Test-ConfigurationDataExpressionParentheses {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[AllowNull()]
|
|
[string]
|
|
$Expression
|
|
)
|
|
|
|
if([string]::IsNullOrWhiteSpace($Expression)){
|
|
return $true
|
|
}
|
|
|
|
$Depth = 0
|
|
$InString = $false
|
|
|
|
for($Index = 0; $Index -lt $Expression.Length; $Index++){
|
|
$Character = $Expression[$Index]
|
|
|
|
if($Character -eq "'"){
|
|
$InString = -not $InString
|
|
continue
|
|
}
|
|
|
|
if($InString){
|
|
continue
|
|
}
|
|
|
|
if($Character -eq "("){
|
|
$Depth++
|
|
}elseif($Character -eq ")"){
|
|
$Depth--
|
|
if($Depth -lt 0){
|
|
return $false
|
|
}
|
|
}
|
|
}
|
|
|
|
return $Depth -eq 0 -and -not $InString
|
|
}
|