|
|
@ -80,6 +80,8 @@ func TestTranslations(t *testing.T) { |
|
|
|
LteFieldString string `validate:"ltefield=MaxString"` |
|
|
|
LteFieldString string `validate:"ltefield=MaxString"` |
|
|
|
AlphaString string `validate:"alpha"` |
|
|
|
AlphaString string `validate:"alpha"` |
|
|
|
AlphanumString string `validate:"alphanum"` |
|
|
|
AlphanumString string `validate:"alphanum"` |
|
|
|
|
|
|
|
AlphanumUnicodeString string `validate:"alphanumunicode"` |
|
|
|
|
|
|
|
AlphaUnicodeString string `validate:"alphaunicode"` |
|
|
|
NumericString string `validate:"numeric"` |
|
|
|
NumericString string `validate:"numeric"` |
|
|
|
NumberString string `validate:"number"` |
|
|
|
NumberString string `validate:"number"` |
|
|
|
HexadecimalString string `validate:"hexadecimal"` |
|
|
|
HexadecimalString string `validate:"hexadecimal"` |
|
|
@ -94,9 +96,12 @@ func TestTranslations(t *testing.T) { |
|
|
|
Base64 string `validate:"base64"` |
|
|
|
Base64 string `validate:"base64"` |
|
|
|
Contains string `validate:"contains=purpose"` |
|
|
|
Contains string `validate:"contains=purpose"` |
|
|
|
ContainsAny string `validate:"containsany=!@#$"` |
|
|
|
ContainsAny string `validate:"containsany=!@#$"` |
|
|
|
|
|
|
|
ContainsRune string `validate:"containsrune=☻"` |
|
|
|
Excludes string `validate:"excludes=text"` |
|
|
|
Excludes string `validate:"excludes=text"` |
|
|
|
ExcludesAll string `validate:"excludesall=!@#$"` |
|
|
|
ExcludesAll string `validate:"excludesall=!@#$"` |
|
|
|
ExcludesRune string `validate:"excludesrune=☻"` |
|
|
|
ExcludesRune string `validate:"excludesrune=☻"` |
|
|
|
|
|
|
|
EndsWith string `validate:"endswith=end"` |
|
|
|
|
|
|
|
StartsWith string `validate:"startswith=start"` |
|
|
|
ISBN string `validate:"isbn"` |
|
|
|
ISBN string `validate:"isbn"` |
|
|
|
ISBN10 string `validate:"isbn10"` |
|
|
|
ISBN10 string `validate:"isbn10"` |
|
|
|
ISBN13 string `validate:"isbn13"` |
|
|
|
ISBN13 string `validate:"isbn13"` |
|
|
@ -172,6 +177,8 @@ func TestTranslations(t *testing.T) { |
|
|
|
|
|
|
|
|
|
|
|
test.AlphaString = "abc3" |
|
|
|
test.AlphaString = "abc3" |
|
|
|
test.AlphanumString = "abc3!" |
|
|
|
test.AlphanumString = "abc3!" |
|
|
|
|
|
|
|
test.AlphanumUnicodeString = "abc3啊!" |
|
|
|
|
|
|
|
test.AlphaUnicodeString = "abc3啊" |
|
|
|
test.NumericString = "12E.00" |
|
|
|
test.NumericString = "12E.00" |
|
|
|
test.NumberString = "12E" |
|
|
|
test.NumberString = "12E" |
|
|
|
|
|
|
|
|
|
|
@ -179,6 +186,9 @@ func TestTranslations(t *testing.T) { |
|
|
|
test.ExcludesAll = "This is Great!" |
|
|
|
test.ExcludesAll = "This is Great!" |
|
|
|
test.ExcludesRune = "Love it ☻" |
|
|
|
test.ExcludesRune = "Love it ☻" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test.EndsWith = "this is some test text" |
|
|
|
|
|
|
|
test.StartsWith = "this is some test text" |
|
|
|
|
|
|
|
|
|
|
|
test.ASCII = "カタカナ" |
|
|
|
test.ASCII = "カタカナ" |
|
|
|
test.PrintableASCII = "カタカナ" |
|
|
|
test.PrintableASCII = "カタカナ" |
|
|
|
|
|
|
|
|
|
|
@ -329,6 +339,14 @@ func TestTranslations(t *testing.T) { |
|
|
|
ns: "Test.ISBN13", |
|
|
|
ns: "Test.ISBN13", |
|
|
|
expected: "ISBN13必须是一个有效的ISBN-13编号", |
|
|
|
expected: "ISBN13必须是一个有效的ISBN-13编号", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.EndsWith", |
|
|
|
|
|
|
|
expected: "EndsWith必须以文本'end'结尾", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StartsWith", |
|
|
|
|
|
|
|
expected: "StartsWith必须以文本'start'开头", |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.Excludes", |
|
|
|
ns: "Test.Excludes", |
|
|
|
expected: "Excludes不能包含文本'text'", |
|
|
|
expected: "Excludes不能包含文本'text'", |
|
|
@ -341,6 +359,10 @@ func TestTranslations(t *testing.T) { |
|
|
|
ns: "Test.ExcludesRune", |
|
|
|
ns: "Test.ExcludesRune", |
|
|
|
expected: "ExcludesRune不能包含'☻'", |
|
|
|
expected: "ExcludesRune不能包含'☻'", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.ContainsRune", |
|
|
|
|
|
|
|
expected: "ContainsRune必须包含字符'☻'", |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.ContainsAny", |
|
|
|
ns: "Test.ContainsAny", |
|
|
|
expected: "ContainsAny必须包含至少一个以下字符'!@#$'", |
|
|
|
expected: "ContainsAny必须包含至少一个以下字符'!@#$'", |
|
|
@ -397,6 +419,14 @@ func TestTranslations(t *testing.T) { |
|
|
|
ns: "Test.NumericString", |
|
|
|
ns: "Test.NumericString", |
|
|
|
expected: "NumericString必须是一个有效的数值", |
|
|
|
expected: "NumericString必须是一个有效的数值", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.AlphaUnicodeString", |
|
|
|
|
|
|
|
expected: "AlphaUnicodeString只能包含字母和Unicode字符", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.AlphanumUnicodeString", |
|
|
|
|
|
|
|
expected: "AlphanumUnicodeString只能包含字母数字和Unicode字符", |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.AlphanumString", |
|
|
|
ns: "Test.AlphanumString", |
|
|
|
expected: "AlphanumString只能包含字母和数字", |
|
|
|
expected: "AlphanumString只能包含字母和数字", |
|
|
|