ValidateRange

noun

say it: “VAL-uh-dayt raynj” /ˈvælədeɪt reɪndʒ/

A rule above a PowerShell parameter that allows only numbers between a lowest and a highest value.

What does ValidateRange do?

[ValidateRange()] lets a number parameter take only values between a lowest and a highest, both included. A song of 45 minutes is stopped before the function runs.

param(
    [ValidateRange(1, 15)]
    [int]$Minutes
)
# Add-Song -Minutes 45 stops: The 45 argument is greater than the maximum allowed range of 15. ...

In a sentence

  • “Sam set ValidateRange to 1 and 15 for -Minutes.”
  • “ValidateRange refused 45 because songs can be 1 to 15 minutes.”

Level: Journeyman · More PowerShell terms at this level

Updated