ValidatePattern
Better error messages for PowerShell ValidatePattern
By Joel 'Jaykul' Bennett on 15-Jun-2010
If you’ve been writing advanced PowerShell 2.0 functions, you’ve probably used some of the Validate* attributes to enforce valid parameter values, and you may have noticed that their error messages leave a lot to be desired. For example, imagine that you have a parameter which takes a 10-digit phone number: function Test-PhoneNumber { param( [ValidatePattern(’^\(?\d{3}\)?\s.]?\d{3}[\s.]\d{4}$’)]$number [...]
Posted in Huddled | Tagged Attribute, Error message, PowerShell, ValidatePattern | 3 Responses