Add parameter validation functions and enhance tests for configuration data
This commit is contained in:
@@ -42,6 +42,7 @@ function Assert-ConfigurationDataParameter {
|
||||
return
|
||||
}
|
||||
|
||||
Assert-ConfigurationDataParameterType -Name $Name -Definition $Definition -Value $Value
|
||||
Assert-ConfigurationDataParameterAllowedValue -Name $Name -Definition $Definition -Value $Value
|
||||
|
||||
if(Test-ConfigurationDataMapContainsKey -Map $Definition -Key "MinLength"){
|
||||
@@ -64,4 +65,20 @@ function Assert-ConfigurationDataParameter {
|
||||
throw "Parameter [$Name] value [$Value] does not match pattern [$Pattern]."
|
||||
}
|
||||
}
|
||||
|
||||
if(Test-ConfigurationDataMapContainsKey -Map $Definition -Key "MinValue"){
|
||||
Assert-ConfigurationDataParameterNumericValue -Name $Name -Value $Value
|
||||
$MinValue = [decimal](Get-ConfigurationDataMapValue -Map $Definition -Key "MinValue")
|
||||
if(([decimal]$Value) -lt $MinValue){
|
||||
throw "Parameter [$Name] value [$Value] is less than MinValue [$MinValue]."
|
||||
}
|
||||
}
|
||||
|
||||
if(Test-ConfigurationDataMapContainsKey -Map $Definition -Key "MaxValue"){
|
||||
Assert-ConfigurationDataParameterNumericValue -Name $Name -Value $Value
|
||||
$MaxValue = [decimal](Get-ConfigurationDataMapValue -Map $Definition -Key "MaxValue")
|
||||
if(([decimal]$Value) -gt $MaxValue){
|
||||
throw "Parameter [$Name] value [$Value] is greater than MaxValue [$MaxValue]."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user