Skip to content

ValidateSet should support a dynamically generated set from a script block #8651

@OlsonDev

Description

@OlsonDev

Summary of the new feature/enhancement

As a PowerShell user, I want [ValidateSet] to support a dynamically generated sets from script blocks so that I can make terse, reusable sets of data, and my coworkers are provided useful IntelliSense from my work. In issue #3744, it was proposed to support a dynamically generated set for [ValidateSet]. An example was given with a script block, which would resolve the set. However, the actual merged PR laid the groundwork and implemented a variant, using classes and interfaces. I'd like this issue to specifically track the ability to use [ValidateSet] with a script block and receive IntelliSense feedback.

Proposed technical implementation details

For example:

[CmdletBinding()]
param (
    [ValidateSet({ (Get-MyGitRepos -Code -Config).master })]
    $Repo = "foo"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions