diff options
Diffstat (limited to 'modules/validation/regex_pattern_test.go')
-rw-r--r-- | modules/validation/regex_pattern_test.go | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/modules/validation/regex_pattern_test.go b/modules/validation/regex_pattern_test.go index efcb276734..80790a23b1 100644 --- a/modules/validation/regex_pattern_test.go +++ b/modules/validation/regex_pattern_test.go @@ -17,39 +17,39 @@ func getRegexPatternErrorString(pattern string) string { return "" } -var regexValidationTestCases = []validationTestCase{ - { - description: "Empty regex pattern", - data: TestForm{ - RegexPattern: "", - }, - expectedErrors: binding.Errors{}, - }, - { - description: "Valid regex", - data: TestForm{ - RegexPattern: `(\d{1,3})+`, - }, - expectedErrors: binding.Errors{}, - }, +func Test_RegexPatternValidation(t *testing.T) { + AddBindingRules() - { - description: "Invalid regex", - data: TestForm{ - RegexPattern: "[a-", + regexValidationTestCases := []validationTestCase{ + { + description: "Empty regex pattern", + data: TestForm{ + RegexPattern: "", + }, + expectedErrors: binding.Errors{}, }, - expectedErrors: binding.Errors{ - binding.Error{ - FieldNames: []string{"RegexPattern"}, - Classification: ErrRegexPattern, - Message: getRegexPatternErrorString("[a-"), + { + description: "Valid regex", + data: TestForm{ + RegexPattern: `(\d{1,3})+`, }, + expectedErrors: binding.Errors{}, }, - }, -} -func Test_RegexPatternValidation(t *testing.T) { - AddBindingRules() + { + description: "Invalid regex", + data: TestForm{ + RegexPattern: "[a-", + }, + expectedErrors: binding.Errors{ + binding.Error{ + FieldNames: []string{"RegexPattern"}, + Classification: ErrRegexPattern, + Message: getRegexPatternErrorString("[a-"), + }, + }, + }, + } for _, testCase := range regexValidationTestCases { t.Run(testCase.description, func(t *testing.T) { |