PowerShell / Crescendo

a module for wrapping native applications in a PowerShell function and module
MIT License
397 stars 37 forks source link

Support Validate Parameter Input #197

Closed DennisL68 closed 1 year ago

DennisL68 commented 1 year ago

Summary of the new feature / enhancement

As a PowerShell scripter I often like to validate the parameter input from the user to avoid running commands with parameters that eventually would fail anyway

Proposed technical implementation details (optional)

Add options to parameters for validations normally supported on input parameters in PowerShell

theJasonHelmick commented 1 year ago

Hi @DennisL68 - Thank you for the issue. This is supported today with PowerShell advanced functions validate attributes. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.3#validatecount-validation-attribute

DennisL68 commented 1 year ago

Yes, I am aware of the Advanced functions feature.

But can it be added to the JSON-configuration? It seems to be a very good improvement for Crescendo.

theJasonHelmick commented 1 year ago

These are supported today in the json as well -- Check out our samples folder https://github.com/PowerShell/Crescendo/tree/master/Microsoft.PowerShell.Crescendo/Samples and additional docs here: https://learn.microsoft.com/en-us/powershell/utility-modules/crescendo/get-started/create-new-cmdlet?view=ps-modules