The errors provided when a parameter validates a [ValidatePattern("somehorribleregex")] is hard to interpret for the user.
It would be useful to be able to provide a human readable error message when the validation fails. Regexs are powerful, but not readable.
Any yes, even if localization may be an issue, it is still better than the regex. :)
param(
[ValidatePattern('[A-Z]:', ErrorMessage='The Drive should be specified as a single letter followed by a colon, for example "D:"')]
[string] $Drive,
[ValidatePattern('\\\\\w+\\\w+', ErrorMessage='The NetworkShare should be specified on the following format: "\\computer\sharename"')]
[string] $NetworkShare
)
The errors provided when a parameter validates a [ValidatePattern("somehorribleregex")] is hard to interpret for the user.
It would be useful to be able to provide a human readable error message when the validation fails. Regexs are powerful, but not readable.
Any yes, even if localization may be an issue, it is still better than the regex. :)