Skip to content

Commit

Permalink
Merge pull request #16 from skybet/GS-1926
Browse files Browse the repository at this point in the history
[refs GS-1926] Correct regex and add tests
  • Loading branch information
andrewmunro authored Oct 14, 2019
2 parents 35dd8de + 2d2e4fd commit 0af6955
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const (
ISBN10 string = "^(?:[0-9]{9}X|[0-9]{10})$"
ISBN13 string = "^(?:[0-9]{13})$"
UUID3 string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-3[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
UUID4 string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
UUID5 string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-5[0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
UUID4 string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
UUID5 string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-5[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
UUID string = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
Alpha string = "^[a-zA-Z]+$"
Alphanumeric string = "^[a-zA-Z0-9]+$"
Expand Down
8 changes: 8 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,8 @@ func TestIsUUID(t *testing.T) {
{"987fbc9-4bed-3078-cf07a-9141ba07c9f3", false},
{"aaaaaaaa-1111-1111-aaag-111111111111", false},
{"a987fbc9-4bed-3078-cf07-9141ba07c9f3", true},
{"A987FBC9-4BED-3078-CF07-9141BA07C9F3", true},
{"a987fBc9-4bEd-3078-Cf07-9141bA07c9f3", true},
}
for _, test := range tests {
actual := IsUUID(test.param)
Expand All @@ -1283,6 +1285,8 @@ func TestIsUUID(t *testing.T) {
{"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3", false},
{"a987fbc9-4bed-4078-8f07-9141ba07c9f3", false},
{"a987fbc9-4bed-3078-cf07-9141ba07c9f3", true},
{"A987FBC9-4BED-3078-CF07-9141BA07C9F3", true},
{"a987fBc9-4bEd-3078-Cf07-9141bA07c9f3", true},
}
for _, test := range tests {
actual := IsUUIDv3(test.param)
Expand All @@ -1302,6 +1306,8 @@ func TestIsUUID(t *testing.T) {
{"934859", false},
{"57b73598-8764-4ad0-a76a-679bb6640eb1", true},
{"625e63f3-58f5-40b7-83a1-a72ad31acffb", true},
{"625E63F3-58F5-40B7-83A1-A72AD31ACFFB", true},
{"625E63f3-58F5-40b7-83A1-a72Ad31AcFfB", true},
}
for _, test := range tests {
actual := IsUUIDv4(test.param)
Expand All @@ -1322,6 +1328,8 @@ func TestIsUUID(t *testing.T) {
{"a987fbc9-4bed-3078-cf07-9141ba07c9f3", false},
{"987fbc97-4bed-5078-af07-9141ba07c9f3", true},
{"987fbc97-4bed-5078-9f07-9141ba07c9f3", true},
{"987FBC97-4BED-5078-9F07-9141BA07C9F3", true},
{"987FbC97-4bEd-5078-9f07-9141bA07c9f3", true},
}
for _, test := range tests {
actual := IsUUIDv5(test.param)
Expand Down

0 comments on commit 0af6955

Please sign in to comment.