28 lines
693 B
PowerShell
28 lines
693 B
PowerShell
function Assert-ConfigurationDataParameterAllowedValue {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]
|
|
$Name,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
$Definition,
|
|
|
|
[AllowNull()]
|
|
$Value
|
|
)
|
|
|
|
if(-not (Test-ConfigurationDataMapContainsKey -Map $Definition -Key "AllowedValues")){
|
|
return
|
|
}
|
|
|
|
$AllowedValues = @(Get-ConfigurationDataMapValue -Map $Definition -Key "AllowedValues")
|
|
if($AllowedValues.Count -eq 0){
|
|
return
|
|
}
|
|
|
|
if($AllowedValues -notcontains $Value){
|
|
throw "Parameter [$Name] value [$Value] is not allowed. Allowed values are: $($AllowedValues -join ', ')."
|
|
}
|
|
}
|