Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Example validation: Fails if a parameter has a ValidateSet #242

Open
johlju opened this issue Jul 1, 2018 · 0 comments
Open

Example validation: Fails if a parameter has a ValidateSet #242

johlju opened this issue Jul 1, 2018 · 0 comments
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.

Comments

@johlju
Copy link
Contributor

johlju commented Jul 1, 2018

The following code does not take in account if there are a validate set on a mandatory parameter.
Also, this code should be split out to a separate function.

<#
Check for mandatory parameters.
Assume the parameters are all in the 'all' parameter set.
#>
$isParameterMandatory = $exampleCommand.Parameters[$parameterName].ParameterSets['__AllParameterSets'].IsMandatory
if ($isParameterMandatory)
{
<#
Convert '1' to the type that the parameter expects.
Using '1' since it can be converted to String, Numeric
and Boolean.
#>
$exampleParameters.Add($parameterName, ('1' -as $parameterType))
}

@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Jul 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

1 participant