forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_management.go
36 lines (26 loc) · 1.05 KB
/
api_management.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
29
30
31
32
33
34
35
36
package validate
import (
"fmt"
"regexp"
)
func ApiManagementServiceName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,50}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes up to 50 characters in length", k))
}
return warnings, errors
}
func ApiManagementServicePublisherName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if matched := regexp.MustCompile(`^.{1,100}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only be up to 100 characters in length", k))
}
return warnings, errors
}
func ApiManagementServicePublisherEmail(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)
if matched := regexp.MustCompile(`^[\S*]{1,100}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only be up to 100 characters in length", k))
}
return warnings, errors
}