implementing validator tests

pull/753/head
Lucas Mendes Loureiro 4 years ago
parent c304f52add
commit af4caa104a
  1. 5
      go.mod
  2. 6
      go.sum
  3. 6
      translations/en/en_test.go
  4. 8
      translations/es/es_test.go
  5. 8
      translations/fr/fr_test.go
  6. 8
      translations/id/id_test.go
  7. 8
      translations/ja/ja_test.go
  8. 8
      translations/nl/nl_test.go
  9. 6
      translations/pt/pt_test.go
  10. 8
      translations/pt_BR/pt_BR_test.go
  11. 6
      translations/ru/ru_test.go
  12. 8
      translations/tr/tr_test.go
  13. 6
      translations/zh/zh_test.go
  14. 6
      translations/zh_tw/zh_tw_test.go

@ -7,6 +7,9 @@ require (
github.com/go-playground/locales v0.13.0
github.com/go-playground/universal-translator v0.17.0
github.com/leodido/go-urn v1.2.0
github.com/lucasmendesl/validator v9.31.0+incompatible // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/text v0.3.2 // indirect
golang.org/x/text v0.3.2
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
)

@ -8,6 +8,8 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lucasmendesl/validator v9.31.0+incompatible h1:kiNduc38Ha9IcUxU748i/3rhgKYF8QC8n9z9ufrCp+0=
github.com/lucasmendesl/validator v9.31.0+incompatible/go.mod h1:N8FdZMEBYHc9h4qMPmyCfq28BSvnOdmNyflwJA8rw64=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
@ -29,5 +31,9 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IK
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M=
gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -182,6 +183,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -340,6 +342,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesAll",
expected: "ExcludesAll cannot contain any of the following characters '!@#$'",
},
{
ns: "Test.Regex",
expected: "Regex is not in the correct format",
},
{
ns: "Test.ExcludesRune",
expected: "ExcludesRune cannot contain the following '☻'",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
spanish "github.com/go-playground/locales/es"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -178,6 +179,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -336,6 +338,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune no puede contener lo siguiente '☻'",
},
{
ns: "Test.Regex",
expected: "Regex no tiene el formato correcto",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny debe contener al menos uno de los siguientes caracteres '!@#$'",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
french "github.com/go-playground/locales/fr"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -175,6 +176,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -330,6 +332,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune ne doit pas contenir ce qui suit '☻'",
},
{
ns: "Test.Regex",
expected: "Regex n'est pas au bon format",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny doit contenir au moins l' un des caractères suivants '!@#$'",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
indonesia "github.com/go-playground/locales/id"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -175,6 +176,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -330,6 +332,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune tidak boleh berisi '☻'",
},
{
ns: "Test.Regex",
expected: "Format Regex salah",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny harus berisi setidaknya salah satu karakter berikut '!@#$'",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
ja_locale "github.com/go-playground/locales/ja"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -175,6 +176,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -330,6 +332,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRuneには'☻'を含めることはできません",
},
{
ns: "Test.Regex",
expected: "Regexは正しい形式ではありません",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAnyは'!@#$'の少なくとも1つを含まなければなりません",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
english "github.com/go-playground/locales/en"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -175,6 +176,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -330,6 +332,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune mag niet het volgende bevatten '☻'",
},
{
ns: "Test.Regex",
expected: "Regex is not in the correct format",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny moet tenminste een van de volgende karakters bevatten '!@#$'",

@ -98,6 +98,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -183,6 +184,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -345,6 +347,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune não pode conter o seguinte '☻'",
},
{
ns: "Test.Regex",
expected: "Regex não está no formato correto",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny deve conter pelo menos um dos seguintes caracteres '!@#$'",

@ -4,10 +4,10 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
brazilian_portuguese "github.com/go-playground/locales/pt_BR"
ut "github.com/go-playground/universal-translator"
"github.com/go-playground/validator/v10"
. "github.com/go-playground/assert/v2"
)
func TestTranslations(t *testing.T) {
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -175,6 +176,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "Isso é Ótimo!"
test.ExcludesRune = "Amo isso ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -330,6 +332,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune não deve conter '☻'",
},
{
ns: "Test.Regex",
expected: "Regex não está no formato correto",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny deve conter pelo menos um dos caracteres '!@#$'",

@ -99,6 +99,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -180,6 +181,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -338,6 +340,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune не должен содержать '☻'",
},
{
ns: "Test.Regex",
expected: "Regex имеет неправильный формат",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny должен содержать минимум один из символов '!@#$'",

@ -4,9 +4,9 @@ import (
"testing"
"time"
. "github.com/go-playground/assert/v2"
turkish "github.com/go-playground/locales/tr"
ut "github.com/go-playground/universal-translator"
. "github.com/go-playground/assert/v2"
"github.com/go-playground/validator/v10"
)
@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -178,6 +179,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -336,6 +338,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune, '☻' ifadesini içeremez",
},
{
ns: "Test.Regex",
expected: "Regex doğru biçimde değil",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny, '!@#$' karakterlerinden en az birini içermelidir",

@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -179,6 +180,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -341,6 +343,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune不能包含'☻'",
},
{
ns: "Test.Regex",
expected: "Regex的格式不正確",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny必须包含至少一个以下字符'!@#$'",

@ -97,6 +97,7 @@ func TestTranslations(t *testing.T) {
Excludes string `validate:"excludes=text"`
ExcludesAll string `validate:"excludesall=!@#$"`
ExcludesRune string `validate:"excludesrune=☻"`
Regex string `validate:"regex=[0-9]"`
ISBN string `validate:"isbn"`
ISBN10 string `validate:"isbn10"`
ISBN13 string `validate:"isbn13"`
@ -176,6 +177,7 @@ func TestTranslations(t *testing.T) {
test.ExcludesAll = "This is Great!"
test.ExcludesRune = "Love it ☻"
test.Regex = "abctest"
test.ASCII = "カタカナ"
test.PrintableASCII = "カタカナ"
@ -333,6 +335,10 @@ func TestTranslations(t *testing.T) {
ns: "Test.ExcludesRune",
expected: "ExcludesRune不能包含'☻'",
},
{
ns: "Test.Regex",
expected: "Regex的格式不正確",
},
{
ns: "Test.ContainsAny",
expected: "ContainsAny必須包含至少一個以下字元'!@#$'",

Loading…
Cancel
Save