-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add subnet and virtual network name validation (#376)
Resolves #268 issue
- Loading branch information
1 parent
c18b0ec
commit b6ca3a4
Showing
4 changed files
with
61 additions
and
6 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
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,41 @@ | ||
package validate_test | ||
|
||
import ( | ||
"github.com/multycloud/multy/validate" | ||
"regexp" | ||
"testing" | ||
) | ||
|
||
// TestWordWithDotHyphenUnder80Pattern checks whether validate.WordWithDotHyphenUnder80Pattern matches | ||
// expected expressions | ||
func TestWordWithDotHyphenUnder80Pattern(t *testing.T) { | ||
testRegexp, err := regexp.Compile(validate.WordWithDotHyphenUnder80Pattern) | ||
if err != nil { | ||
t.Fatalf("Could not compile regex: %s", validate.WordWithDotHyphenUnder80Pattern) | ||
} | ||
|
||
shouldMatch := []string{ | ||
"a", | ||
"9", | ||
"aZ9", | ||
"ThisIs67dots..................................................................._", | ||
} | ||
shouldntMatch := []string{ | ||
"", | ||
"_", | ||
"<someName", | ||
"ThisIs68dots...................................................................._", | ||
"Maybe?inThe.Middle_", | ||
} | ||
|
||
for _, name := range shouldMatch { | ||
if !testRegexp.MatchString(name) { | ||
t.Errorf("%s should match %s, but didn't", validate.WordWithDotHyphenUnder80Pattern, name) | ||
} | ||
} | ||
for _, name := range shouldntMatch { | ||
if testRegexp.MatchString(name) { | ||
t.Errorf("%s shouldn't match %s, but did", validate.WordWithDotHyphenUnder80Pattern, name) | ||
} | ||
} | ||
} |