At times, you may also have requirements as to what constitutes an acceptable parameter.
Net BIOS limitations may limit a computer name to 15 characters or less.
In that case, handle the validation of a collection with a foreach loop in the main code.
With all the options for parameter validation at your fingertips, there is no good reason to not use it.
As a result, using validation will specifically state that you are not allowing the values.
This is different from having to figure out how the function would behave with invalid parameters and rely on the default handling for the parameter.
You were taught that your program should nicely tell the user what was wrong and how to fix the problem.
Note that this is only possible to validate a single parameter and not a collection.
Power Shell provides ways to validate acceptable parameter input for a function or a script.
If you have taken an introductory computer science or programming course, you have learned first-hand about the importance of validating the values of parameters passed into your script, function, or program.
Conversely, ensure that a null or empty value is not accepted as an input parameter by using the Validate Not Null() or Validate Not Nullor Empty() parameter validation attributes.
The behavior in the simple example, when using the validate settings, shows a similar error compared to the behavior in the original example with no parameter validation.
Though the error messages are fairly clear about the problem, perhaps you want to allow for these conditions to be valid so that the function does not err or give nasty red messages.