Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should platyPS support/document Validation Sets? #560

Open
SPMatthewMcD opened this issue Feb 17, 2022 · 6 comments
Open

Should platyPS support/document Validation Sets? #560

SPMatthewMcD opened this issue Feb 17, 2022 · 6 comments
Labels
Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation.

Comments

@SPMatthewMcD
Copy link

I noticed in my latest build that Validation sets are not enumerated.

Should they be? I ended up adding the enumeration myself to the Region parameter here: https://github.com/SpanningCloudApps/SB365-Powershell/blob/master/docs/Get-SpanningAuthentication.md

Thanks

@sdwheeler
Copy link
Collaborator

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
Copy link
Author

Thanks for the response.

@SPMatthewMcD
Copy link
Author

@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.

@sdwheeler
Copy link
Collaborator

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.

@sdwheeler sdwheeler reopened this Feb 25, 2022
@SPMatthewMcD
Copy link
Author

Understood, thanks. I'll try and dig in to see if I can contribute.

@sdwheeler sdwheeler added this to the Future-Consider milestone Apr 4, 2022
@sdwheeler sdwheeler added Needs investigation Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation. and removed Issue Investigation labels Apr 4, 2022
@ThomasNieto
Copy link
Contributor

ThomasNieto commented May 8, 2023

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-Command Get-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation.
Projects
None yet
Development

No branches or pull requests

3 participants