Add parameter validation functions and enhance tests for configuration data
This commit is contained in:
21
Private/Assert-ConfigurationDataParameterNumericValue.ps1
Normal file
21
Private/Assert-ConfigurationDataParameterNumericValue.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
function Assert-ConfigurationDataParameterNumericValue {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Name,
|
||||
|
||||
[AllowNull()]
|
||||
$Value
|
||||
)
|
||||
|
||||
if($null -eq $Value -or $Value -is [bool] -or ($Value -isnot [ValueType])){
|
||||
throw "Parameter [$Name] value [$Value] is not numeric."
|
||||
}
|
||||
|
||||
try {
|
||||
[void]([decimal]$Value)
|
||||
} catch {
|
||||
throw "Parameter [$Name] value [$Value] is not numeric."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user