-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Now that at least some of the custom error messages for parameter validation attributes support custom error messages - see #3745, it should be possible to support localization of these error messages - currently, only literal strings are supported.
Without this ability, localized scripts are effectively prevented from using such validation attributes.
What currently works:
function foo {
param(
[ValidatePattern('o', ErrorMessage = 'Must have an "o".')]
$bar
)
$bar
}
foo -bar bazThis yields:
foo : Cannot validate argument on parameter 'bar'. Must have an "o".
What support for localization might look like (not sure about feasibility; solely based on noticing that some attributes accept script blocks):
$stringTable = DATA {
@{
msg = 'Must have an "o".'
}
}
function foo {
param(
[ValidatePattern('o', ErrorMessage = { $stringTable.msg })]
$bar
)
$bar
}
foo -bar bazEnvironment data
PowerShell Core v6.0.0-beta (v6.0.0-beta.1)Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime