By Joel 'Jaykul' Bennett on 31-Jan-2011
I wrote a post awhile back about using custom attributes for PowerShell parameter validation but when I did it, I focused on the use of attributes to improve the error messages output by validation (specifically, by: ValidatePattern). There are many other things that can be done with custom attributes. However, PowerShell ships with two base [...]
Posted in Huddled | Tagged Attribute, C++, PowerShell, Transformation, Type Cast |
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 |