-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maksymilian Boguń
committed
Jun 14, 2019
1 parent
4320131
commit b1872b8
Showing
10 changed files
with
690 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package validate | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
) | ||
|
||
func StorageContainerName(v interface{}, k string) (warnings []string, errors []error) { | ||
value := v.(string) | ||
if !regexp.MustCompile(`^\$root$|^[0-9a-z-]+$`).MatchString(value) { | ||
errors = append(errors, fmt.Errorf( | ||
"only lowercase alphanumeric characters and hyphens allowed in %q: %q", | ||
k, value)) | ||
} | ||
if len(value) < 3 || len(value) > 63 { | ||
errors = append(errors, fmt.Errorf( | ||
"%q must be between 3 and 63 characters: %q", k, value)) | ||
} | ||
if regexp.MustCompile(`^-`).MatchString(value) { | ||
errors = append(errors, fmt.Errorf( | ||
"%q cannot begin with a hyphen: %q", k, value)) | ||
} | ||
return warnings, errors | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.