Vscode-powershell: Gramatically incorrect error message

Created on 3 Apr 2020  Â·  2Comments  Â·  Source: PowerShell/vscode-powershell

System Details

Windows PowerShell 5.1
PowerShell 7.0
PowerShell 7.1 Preview 1

Issue Description

A gramatically incorrect error message is returned when the length of a string
parameter's argument exceeds the range specified by a ValidateLengthAttribute.

Function Test-ValidateLength {
    param(
        [ValidateLength(1,5)][string]$Text
    )
}
Test-ValidateLength '123456'

Expected Behaviour

"Cannot validate argument on parameter 'Text'. The character length (6) of the argument is
too long. Shorten the character length …"

Actual Behaviour

"Cannot validate argument on parameter 'Text'. The character length of the 6 argument is
too long. Shorten the character length …"

PowerShell-Bug Resolution-External

All 2 comments

Looks like simply changing Line 178 to look similar to line 175.

That being said, it would probably be a good idea to open this issue over there instead: https://github.com/PowerShell/PowerShell/issues/new/choose

I did as you suggested and opened a "Documentation issue".

Was this page helpful?
0 / 5 - 0 ratings