initial Commit
This commit is contained in:
27
Private/Assert-ConfigurationDataParameterAllowedValue.ps1
Normal file
27
Private/Assert-ConfigurationDataParameterAllowedValue.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
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 ', ')."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user