Reputation: 362
I have a script that accepts one or more subdomains, I want to validate them but [ValidatePattern()]
seems to only check the first item in the array.
The code:
param(
[ValidatePattern('\w*\.domain\.com')][string]$subdomain
)
This input gets accepted:
.\script.ps1 -subdomain "test.domain.com", "randomstring"
Is there a way to validate every entry in the array?
Upvotes: 2
Views: 1881
Reputation: 1346
param(
[ValidatePattern('\w*\.domain\.com')][string[]]$subdomain
)
in your script subdomain parameter doesn't accept multiple values.
[string[]]$subdomain
Upvotes: 6