Skip to content

Error message when ValidateLength fails was not proof-read #25566

@jhoneill

Description

@jhoneill

Prerequisites

Steps to reproduce

PS>  function foo {param ( [ValidateLength(0,2)]$bar)
>> $bar
>> }

PS>  foo "11111"
foo: Cannot validate argument on parameter 'bar'. The character length of the 5 argument is too long. Shorten the character length of the argument so it is fewer than or equal to "2" characters, and then try the command again.

PS>

It seems the author meant something like The character length of the "bar" argument is too long at 5 characters. Shorten the character length of the argument so it is fewer than or equal to 2 characters
but it has become "the number of chars argument" and 2 is wrapped in quotes.

Expected behavior

PS>  function foo {param ( [ValidateLength(0,2)]$bar)
>> $bar
>> }

PS>  foo "11111"
The character length of the "bar" argument is too long at 5 characters. Shorten the character length of the argument so it is fewer than or equal to 2 characters`

Actual behavior

PS>  function foo {param ( [ValidateLength(0,2)]$bar)
>> $bar
>> }

PS>  foo "11111"
foo: Cannot validate argument on parameter 'bar'. The character length of the 5 argument is too long. Shorten the character length of the argument so it is fewer than or equal to "2" characters, and then try the command again.

Error details

N/a

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors

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