diff --git a/regexes.go b/regexes.go index 9c1c63423..5ff6557cc 100644 --- a/regexes.go +++ b/regexes.go @@ -9,7 +9,7 @@ const ( alphaUnicodeNumericRegexString = "^[\\p{L}\\p{N}]+$" numericRegexString = "^[-+]?[0-9]+(?:\\.[0-9]+)?$" numberRegexString = "^[0-9]+$" - hexadecimalRegexString = "^(0[xX])?[0-9a-fA-F]+$" + hexadecimalRegexString = "^$|(^(0[xX])?[0-9a-fA-F]+$)" hexColorRegexString = "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$" rgbRegexString = "^rgb\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%)\\s*\\)$" rgbaRegexString = "^rgba\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%)\\s*,\\s*(?:(?:0.[1-9]*)|[01])\\s*\\)$" diff --git a/translations/ar/ar_test.go b/translations/ar/ar_test.go index 93adfe9e9..093c7747d 100644 --- a/translations/ar/ar_test.go +++ b/translations/ar/ar_test.go @@ -201,6 +201,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/en/en_test.go b/translations/en/en_test.go index 9cb6deb5a..808e1959d 100644 --- a/translations/en/en_test.go +++ b/translations/en/en_test.go @@ -205,6 +205,7 @@ func TestTranslations(t *testing.T) { test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" test.BooleanString = "A" + test.HexadecimalString = "xyz" test.Inner.RequiredIf = "abcd" diff --git a/translations/es/es_test.go b/translations/es/es_test.go index 814f2ab6a..edd04a0ef 100644 --- a/translations/es/es_test.go +++ b/translations/es/es_test.go @@ -190,6 +190,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/fa/fa_test.go b/translations/fa/fa_test.go index 1acb8cf2d..e2a60fa3e 100644 --- a/translations/fa/fa_test.go +++ b/translations/fa/fa_test.go @@ -200,6 +200,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/fr/fr_test.go b/translations/fr/fr_test.go index f1ba28077..ead239dd9 100644 --- a/translations/fr/fr_test.go +++ b/translations/fr/fr_test.go @@ -184,6 +184,7 @@ func TestTranslations(t *testing.T) { s := "toolong" test.StrPtrMaxLen = &s test.StrPtrLen = &s + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/id/id_test.go b/translations/id/id_test.go index 5d80940db..7fd5e0ded 100644 --- a/translations/id/id_test.go +++ b/translations/id/id_test.go @@ -184,6 +184,7 @@ func TestTranslations(t *testing.T) { s := "toolong" test.StrPtrMaxLen = &s test.StrPtrLen = &s + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/it/it_test.go b/translations/it/it_test.go index 98d2ab572..f7fc15c3a 100644 --- a/translations/it/it_test.go +++ b/translations/it/it_test.go @@ -211,6 +211,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/ja/ja_test.go b/translations/ja/ja_test.go index 7950251cb..ec9d9be2d 100644 --- a/translations/ja/ja_test.go +++ b/translations/ja/ja_test.go @@ -184,6 +184,7 @@ func TestTranslations(t *testing.T) { s := "toolong" test.StrPtrMaxLen = &s test.StrPtrLen = &s + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/nl/nl_test.go b/translations/nl/nl_test.go index 137e0c408..3db042a9b 100644 --- a/translations/nl/nl_test.go +++ b/translations/nl/nl_test.go @@ -184,6 +184,7 @@ func TestTranslations(t *testing.T) { s := "toolong" test.StrPtrMaxLen = &s test.StrPtrLen = &s + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/pt/pt_test.go b/translations/pt/pt_test.go index 0422ab09b..737f58f41 100644 --- a/translations/pt/pt_test.go +++ b/translations/pt/pt_test.go @@ -199,6 +199,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/pt_BR/pt_BR_test.go b/translations/pt_BR/pt_BR_test.go index 426f24689..a98f4ab65 100644 --- a/translations/pt_BR/pt_BR_test.go +++ b/translations/pt_BR/pt_BR_test.go @@ -186,6 +186,7 @@ func TestTranslations(t *testing.T) { s := "toolong" test.StrPtrMaxLen = &s test.StrPtrLen = &s + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/ru/ru_test.go b/translations/ru/ru_test.go index c74f0d501..8c42de307 100644 --- a/translations/ru/ru_test.go +++ b/translations/ru/ru_test.go @@ -218,6 +218,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/tr/tr_test.go b/translations/tr/tr_test.go index b72329e0a..1b5dc01ed 100644 --- a/translations/tr/tr_test.go +++ b/translations/tr/tr_test.go @@ -190,6 +190,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/vi/vi_test.go b/translations/vi/vi_test.go index 6e1286643..9ced5483a 100644 --- a/translations/vi/vi_test.go +++ b/translations/vi/vi_test.go @@ -200,6 +200,7 @@ func TestTranslations(t *testing.T) { test.UniqueSlice = []string{"1234", "1234"} test.UniqueMap = map[string]string{"key1": "1234", "key2": "1234"} test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/zh/zh_test.go b/translations/zh/zh_test.go index cf76590a3..307147690 100644 --- a/translations/zh/zh_test.go +++ b/translations/zh/zh_test.go @@ -205,6 +205,7 @@ func TestTranslations(t *testing.T) { test.UppercaseString = "abcdefg" test.Datetime = "20060102" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil) diff --git a/translations/zh_tw/zh_tw_test.go b/translations/zh_tw/zh_tw_test.go index 129c51acc..98061b76b 100644 --- a/translations/zh_tw/zh_tw_test.go +++ b/translations/zh_tw/zh_tw_test.go @@ -187,6 +187,7 @@ func TestTranslations(t *testing.T) { test.StrPtrLen = &s test.Datetime = "2008-Feb-01" + test.HexadecimalString = "xyz" err = validate.Struct(test) NotEqual(t, err, nil)