ValidateLength can be applied to a String parameter or a parameter that contains an array of strings. Each string will be tested against the minimum and maximum length:
function Test-ValidateLength {
[CmdletBinding()]
param (
[ValidateLength(2, 6)]
[String[]]$Parameter1
)
}
Any string with a length below the minimum, or above the maximum, will trigger an error.