Validation Attribute
noun
say it: “val-uh-DAY-shun AT-ruh-byoot” /ˌvæləˈdeɪʃən ˈætrəˌbjut/
A rule in square brackets above a parameter that PowerShell checks before the function runs.
What is a validation attribute in PowerShell?
A validation attribute is a rule in square brackets above a parameter. PowerShell checks the value against it before the function starts, and stops with a clear error when it doesn't pass, so the function itself never sees a bad value.
param(
[ValidateRange(1, 15)]
[int]$Minutes
)
In a sentence
- “Sam put one validation attribute above each parameter.”
- “A validation attribute stopped the 45-minute song before Add-Song ran.”
Level: Journeyman · More PowerShell terms at this level
Updated