You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should platyPS support/document Validation Sets? #560
Sean Wheeler (@sdwheeler) I just checked my Pester scripts and they have access to the Function Validation Sets. They are also mentioned in the 2.0 schema doc. platyPS.schema.md I started wading through the code but got lost. Not sure how the module is getting the Function information and what the difference is between PlatyPS and my Pester test. I load the module functions and then call: $Function.Parameters.{$paramName}.Attributes.validvalues to get the enumeration.
Interesting and worth further research. There are several types of validation (range, enums, count, pattern, and script). So we would have to consider how to handle each type.
You can get the parameter attributes by using Get-Command. Here is an example getting the ValidValues property of the ValidateSetAttribute for the Get-Help -Category parameter.
(Get-CommandGet-Help).Parameters['Category'].Attributes |? { $_.GetType().Name -like"Validate*" } | select -ExpandProperty ValidValues
Alias
Cmdlet
Provider
General
FAQ
Glossary
HelpFile
ScriptCommand
Function
Filter
ExternalScript
All
DefaultHelp
DscResource
Class
Configuration
PlatyPS seems to handle Accepted values if its defined in the markdown help but I didn't find where it populates those values when building the markdown help.
Activity
sdwheeler commentedon Feb 22, 2022
PowerShell does not provide a way to discover the validations so there is no way for PlatyPS to do that.
You have to document the validations manually in the description of the parameter.
SPMatthewMcD commentedon Feb 22, 2022
Thanks for the response.
SPMatthewMcD commentedon Feb 22, 2022
Sean Wheeler (@sdwheeler) I just checked my Pester scripts and they have access to the Function Validation Sets. They are also mentioned in the 2.0 schema doc. platyPS.schema.md I started wading through the code but got lost. Not sure how the module is getting the Function information and what the difference is between PlatyPS and my Pester test. I load the module functions and then call:
$Function.Parameters.{$paramName}.Attributes.validvaluesto get the enumeration.sdwheeler commentedon Feb 25, 2022
Interesting and worth further research. There are several types of validation (range, enums, count, pattern, and script). So we would have to consider how to handle each type.
SPMatthewMcD commentedon Feb 25, 2022
Understood, thanks. I'll try and dig in to see if I can contribute.
ThomasNieto commentedon May 8, 2023
You can get the parameter attributes by using
Get-Command. Here is an example getting theValidValuesproperty of theValidateSetAttributefor theGet-Help -Categoryparameter.PlatyPS seems to handle
Accepted valuesif its defined in the markdown help but I didn't find where it populates those values when building the markdown help.