Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ValidateCount parameter-validation attribute error messages are misleading and inflexible #3585

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Steps to reproduce

function foo { param([ValidateCount(2,2)] [string[]] $bar) }; foo 1; foo 1, 2, 3

Expected behavior

An error message indicating that exactly 2 arguments (array elements) are expected.

Actual behavior

Cannot validate argument on parameter 'bar'. The number of provided arguments (1) is fewer than the minimum number of allowed arguments (2). Provide more than 2 arguments, 
and then try the command again.

Cannot validate argument on parameter 'bar'. The number of provided arguments, (3), exceeds the maximum number of allowed arguments (2). Provide fewer than 2 arguments, and 
then try the command again.

Note:

  • The error messages do not take into account that the lower and upper bound are the same.

  • Aside from that, the wording is incorrect: it should say "2 or more" rather than "more than 2" and "2 or fewer" rather than "fewer than 2".

Environment data

PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.