forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iothub.go
28 lines (21 loc) · 900 Bytes
/
iothub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package validate
import (
"fmt"
"regexp"
)
func IoTHubName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
// Portal: The value must contain only alphanumeric characters or the following: -
if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes", k))
}
return warnings, errors
}
func IoTHubConsumerGroupName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
// Portal: The value must contain only alphanumeric characters or the following: - . _
if matched := regexp.MustCompile(`^[0-9a-zA-Z-._]{1,}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes, periods and underscores", k))
}
return warnings, errors
}