|
|
@ -7,7 +7,7 @@ import ( |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
. "github.com/go-playground/assert/v2" |
|
|
|
. "github.com/go-playground/assert/v2" |
|
|
|
russian "github.com/go-playground/locales/en" |
|
|
|
russian "github.com/go-playground/locales/ru" |
|
|
|
ut "github.com/go-playground/universal-translator" |
|
|
|
ut "github.com/go-playground/universal-translator" |
|
|
|
"github.com/go-playground/validator/v10" |
|
|
|
"github.com/go-playground/validator/v10" |
|
|
|
) |
|
|
|
) |
|
|
@ -33,116 +33,136 @@ func TestTranslations(t *testing.T) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type Test struct { |
|
|
|
type Test struct { |
|
|
|
Inner Inner |
|
|
|
Inner Inner |
|
|
|
RequiredString string `validate:"required"` |
|
|
|
RequiredString string `validate:"required"` |
|
|
|
RequiredNumber int `validate:"required"` |
|
|
|
RequiredNumber int `validate:"required"` |
|
|
|
RequiredMultiple []string `validate:"required"` |
|
|
|
RequiredMultiple []string `validate:"required"` |
|
|
|
LenString string `validate:"len=1"` |
|
|
|
LenString string `validate:"len=1"` |
|
|
|
LenNumber float64 `validate:"len=1113.00"` |
|
|
|
LenNumber float64 `validate:"len=1113.00"` |
|
|
|
LenMultiple []string `validate:"len=7"` |
|
|
|
LenMultiple []string `validate:"len=7"` |
|
|
|
MinString string `validate:"min=1"` |
|
|
|
LenMultipleSecond []string `validate:"len=2"` |
|
|
|
MinNumber float64 `validate:"min=1113.00"` |
|
|
|
MinString string `validate:"min=1"` |
|
|
|
MinMultiple []string `validate:"min=7"` |
|
|
|
MinStringMultiple string `validate:"min=2"` |
|
|
|
MaxString string `validate:"max=3"` |
|
|
|
MinStringMultipleSecond string `validate:"min=7"` |
|
|
|
MaxNumber float64 `validate:"max=1113.00"` |
|
|
|
MinNumber float64 `validate:"min=1113.00"` |
|
|
|
MaxMultiple []string `validate:"max=7"` |
|
|
|
MinMultiple []string `validate:"min=7"` |
|
|
|
EqString string `validate:"eq=3"` |
|
|
|
MinMultipleSecond []string `validate:"min=2"` |
|
|
|
EqNumber float64 `validate:"eq=2.33"` |
|
|
|
MaxString string `validate:"max=3"` |
|
|
|
EqMultiple []string `validate:"eq=7"` |
|
|
|
MaxStringSecond string `validate:"max=7"` |
|
|
|
NeString string `validate:"ne="` |
|
|
|
MaxNumber float64 `validate:"max=1113.00"` |
|
|
|
NeNumber float64 `validate:"ne=0.00"` |
|
|
|
MaxMultiple []string `validate:"max=7"` |
|
|
|
NeMultiple []string `validate:"ne=0"` |
|
|
|
MaxMultipleSecond []string `validate:"max=2"` |
|
|
|
LtString string `validate:"lt=3"` |
|
|
|
EqString string `validate:"eq=3"` |
|
|
|
LtNumber float64 `validate:"lt=5.56"` |
|
|
|
EqNumber float64 `validate:"eq=2.33"` |
|
|
|
LtMultiple []string `validate:"lt=2"` |
|
|
|
EqMultiple []string `validate:"eq=7"` |
|
|
|
LtTime time.Time `validate:"lt"` |
|
|
|
NeString string `validate:"ne="` |
|
|
|
LteString string `validate:"lte=3"` |
|
|
|
NeNumber float64 `validate:"ne=0.00"` |
|
|
|
LteNumber float64 `validate:"lte=5.56"` |
|
|
|
NeMultiple []string `validate:"ne=0"` |
|
|
|
LteMultiple []string `validate:"lte=2"` |
|
|
|
LtString string `validate:"lt=3"` |
|
|
|
LteTime time.Time `validate:"lte"` |
|
|
|
LtStringSecond string `validate:"lt=7"` |
|
|
|
GtString string `validate:"gt=3"` |
|
|
|
LtNumber float64 `validate:"lt=5.56"` |
|
|
|
GtNumber float64 `validate:"gt=5.56"` |
|
|
|
LtMultiple []string `validate:"lt=2"` |
|
|
|
GtMultiple []string `validate:"gt=2"` |
|
|
|
LtMultipleSecond []string `validate:"lt=7"` |
|
|
|
GtTime time.Time `validate:"gt"` |
|
|
|
LtTime time.Time `validate:"lt"` |
|
|
|
GteString string `validate:"gte=3"` |
|
|
|
LteString string `validate:"lte=3"` |
|
|
|
GteNumber float64 `validate:"gte=5.56"` |
|
|
|
LteStringSecond string `validate:"lte=7"` |
|
|
|
GteMultiple []string `validate:"gte=2"` |
|
|
|
LteNumber float64 `validate:"lte=5.56"` |
|
|
|
GteTime time.Time `validate:"gte"` |
|
|
|
LteMultiple []string `validate:"lte=2"` |
|
|
|
EqFieldString string `validate:"eqfield=MaxString"` |
|
|
|
LteMultipleSecond []string `validate:"lte=7"` |
|
|
|
EqCSFieldString string `validate:"eqcsfield=Inner.EqCSFieldString"` |
|
|
|
LteTime time.Time `validate:"lte"` |
|
|
|
NeCSFieldString string `validate:"necsfield=Inner.NeCSFieldString"` |
|
|
|
GtString string `validate:"gt=3"` |
|
|
|
GtCSFieldString string `validate:"gtcsfield=Inner.GtCSFieldString"` |
|
|
|
GtStringSecond string `validate:"gt=7"` |
|
|
|
GteCSFieldString string `validate:"gtecsfield=Inner.GteCSFieldString"` |
|
|
|
GtNumber float64 `validate:"gt=5.56"` |
|
|
|
LtCSFieldString string `validate:"ltcsfield=Inner.LtCSFieldString"` |
|
|
|
GtMultiple []string `validate:"gt=2"` |
|
|
|
LteCSFieldString string `validate:"ltecsfield=Inner.LteCSFieldString"` |
|
|
|
GtMultipleSecond []string `validate:"gt=7"` |
|
|
|
NeFieldString string `validate:"nefield=EqFieldString"` |
|
|
|
GtTime time.Time `validate:"gt"` |
|
|
|
GtFieldString string `validate:"gtfield=MaxString"` |
|
|
|
GteString string `validate:"gte=3"` |
|
|
|
GteFieldString string `validate:"gtefield=MaxString"` |
|
|
|
GteStringSecond string `validate:"gte=7"` |
|
|
|
LtFieldString string `validate:"ltfield=MaxString"` |
|
|
|
GteNumber float64 `validate:"gte=5.56"` |
|
|
|
LteFieldString string `validate:"ltefield=MaxString"` |
|
|
|
GteMultiple []string `validate:"gte=2"` |
|
|
|
AlphaString string `validate:"alpha"` |
|
|
|
GteMultipleSecond []string `validate:"gte=7"` |
|
|
|
AlphanumString string `validate:"alphanum"` |
|
|
|
GteTime time.Time `validate:"gte"` |
|
|
|
NumericString string `validate:"numeric"` |
|
|
|
EqFieldString string `validate:"eqfield=MaxString"` |
|
|
|
NumberString string `validate:"number"` |
|
|
|
EqCSFieldString string `validate:"eqcsfield=Inner.EqCSFieldString"` |
|
|
|
HexadecimalString string `validate:"hexadecimal"` |
|
|
|
NeCSFieldString string `validate:"necsfield=Inner.NeCSFieldString"` |
|
|
|
HexColorString string `validate:"hexcolor"` |
|
|
|
GtCSFieldString string `validate:"gtcsfield=Inner.GtCSFieldString"` |
|
|
|
RGBColorString string `validate:"rgb"` |
|
|
|
GteCSFieldString string `validate:"gtecsfield=Inner.GteCSFieldString"` |
|
|
|
RGBAColorString string `validate:"rgba"` |
|
|
|
LtCSFieldString string `validate:"ltcsfield=Inner.LtCSFieldString"` |
|
|
|
HSLColorString string `validate:"hsl"` |
|
|
|
LteCSFieldString string `validate:"ltecsfield=Inner.LteCSFieldString"` |
|
|
|
HSLAColorString string `validate:"hsla"` |
|
|
|
NeFieldString string `validate:"nefield=EqFieldString"` |
|
|
|
Email string `validate:"email"` |
|
|
|
GtFieldString string `validate:"gtfield=MaxString"` |
|
|
|
URL string `validate:"url"` |
|
|
|
GteFieldString string `validate:"gtefield=MaxString"` |
|
|
|
URI string `validate:"uri"` |
|
|
|
LtFieldString string `validate:"ltfield=MaxString"` |
|
|
|
Base64 string `validate:"base64"` |
|
|
|
LteFieldString string `validate:"ltefield=MaxString"` |
|
|
|
Contains string `validate:"contains=purpose"` |
|
|
|
AlphaString string `validate:"alpha"` |
|
|
|
ContainsAny string `validate:"containsany=!@#$"` |
|
|
|
AlphanumString string `validate:"alphanum"` |
|
|
|
Excludes string `validate:"excludes=text"` |
|
|
|
NumericString string `validate:"numeric"` |
|
|
|
ExcludesAll string `validate:"excludesall=!@#$"` |
|
|
|
NumberString string `validate:"number"` |
|
|
|
ExcludesRune string `validate:"excludesrune=☻"` |
|
|
|
HexadecimalString string `validate:"hexadecimal"` |
|
|
|
ISBN string `validate:"isbn"` |
|
|
|
HexColorString string `validate:"hexcolor"` |
|
|
|
ISBN10 string `validate:"isbn10"` |
|
|
|
RGBColorString string `validate:"rgb"` |
|
|
|
ISBN13 string `validate:"isbn13"` |
|
|
|
RGBAColorString string `validate:"rgba"` |
|
|
|
UUID string `validate:"uuid"` |
|
|
|
HSLColorString string `validate:"hsl"` |
|
|
|
UUID3 string `validate:"uuid3"` |
|
|
|
HSLAColorString string `validate:"hsla"` |
|
|
|
UUID4 string `validate:"uuid4"` |
|
|
|
Email string `validate:"email"` |
|
|
|
UUID5 string `validate:"uuid5"` |
|
|
|
URL string `validate:"url"` |
|
|
|
ASCII string `validate:"ascii"` |
|
|
|
URI string `validate:"uri"` |
|
|
|
PrintableASCII string `validate:"printascii"` |
|
|
|
Base64 string `validate:"base64"` |
|
|
|
MultiByte string `validate:"multibyte"` |
|
|
|
Contains string `validate:"contains=purpose"` |
|
|
|
DataURI string `validate:"datauri"` |
|
|
|
ContainsAny string `validate:"containsany=!@#$"` |
|
|
|
Latitude string `validate:"latitude"` |
|
|
|
Excludes string `validate:"excludes=text"` |
|
|
|
Longitude string `validate:"longitude"` |
|
|
|
ExcludesAll string `validate:"excludesall=!@#$"` |
|
|
|
SSN string `validate:"ssn"` |
|
|
|
ExcludesRune string `validate:"excludesrune=☻"` |
|
|
|
IP string `validate:"ip"` |
|
|
|
ISBN string `validate:"isbn"` |
|
|
|
IPv4 string `validate:"ipv4"` |
|
|
|
ISBN10 string `validate:"isbn10"` |
|
|
|
IPv6 string `validate:"ipv6"` |
|
|
|
ISBN13 string `validate:"isbn13"` |
|
|
|
CIDR string `validate:"cidr"` |
|
|
|
UUID string `validate:"uuid"` |
|
|
|
CIDRv4 string `validate:"cidrv4"` |
|
|
|
UUID3 string `validate:"uuid3"` |
|
|
|
CIDRv6 string `validate:"cidrv6"` |
|
|
|
UUID4 string `validate:"uuid4"` |
|
|
|
TCPAddr string `validate:"tcp_addr"` |
|
|
|
UUID5 string `validate:"uuid5"` |
|
|
|
TCPAddrv4 string `validate:"tcp4_addr"` |
|
|
|
ASCII string `validate:"ascii"` |
|
|
|
TCPAddrv6 string `validate:"tcp6_addr"` |
|
|
|
PrintableASCII string `validate:"printascii"` |
|
|
|
UDPAddr string `validate:"udp_addr"` |
|
|
|
MultiByte string `validate:"multibyte"` |
|
|
|
UDPAddrv4 string `validate:"udp4_addr"` |
|
|
|
DataURI string `validate:"datauri"` |
|
|
|
UDPAddrv6 string `validate:"udp6_addr"` |
|
|
|
Latitude string `validate:"latitude"` |
|
|
|
IPAddr string `validate:"ip_addr"` |
|
|
|
Longitude string `validate:"longitude"` |
|
|
|
IPAddrv4 string `validate:"ip4_addr"` |
|
|
|
SSN string `validate:"ssn"` |
|
|
|
IPAddrv6 string `validate:"ip6_addr"` |
|
|
|
IP string `validate:"ip"` |
|
|
|
UinxAddr string `validate:"unix_addr"` // can't fail from within Go's net package currently, but maybe in the future
|
|
|
|
IPv4 string `validate:"ipv4"` |
|
|
|
MAC string `validate:"mac"` |
|
|
|
IPv6 string `validate:"ipv6"` |
|
|
|
IsColor string `validate:"iscolor"` |
|
|
|
CIDR string `validate:"cidr"` |
|
|
|
StrPtrMinLen *string `validate:"min=10"` |
|
|
|
CIDRv4 string `validate:"cidrv4"` |
|
|
|
StrPtrMaxLen *string `validate:"max=1"` |
|
|
|
CIDRv6 string `validate:"cidrv6"` |
|
|
|
StrPtrLen *string `validate:"len=2"` |
|
|
|
TCPAddr string `validate:"tcp_addr"` |
|
|
|
StrPtrLt *string `validate:"lt=1"` |
|
|
|
TCPAddrv4 string `validate:"tcp4_addr"` |
|
|
|
StrPtrLte *string `validate:"lte=1"` |
|
|
|
TCPAddrv6 string `validate:"tcp6_addr"` |
|
|
|
StrPtrGt *string `validate:"gt=10"` |
|
|
|
UDPAddr string `validate:"udp_addr"` |
|
|
|
StrPtrGte *string `validate:"gte=10"` |
|
|
|
UDPAddrv4 string `validate:"udp4_addr"` |
|
|
|
OneOfString string `validate:"oneof=red green"` |
|
|
|
UDPAddrv6 string `validate:"udp6_addr"` |
|
|
|
OneOfInt int `validate:"oneof=5 63"` |
|
|
|
IPAddr string `validate:"ip_addr"` |
|
|
|
UniqueSlice []string `validate:"unique"` |
|
|
|
IPAddrv4 string `validate:"ip4_addr"` |
|
|
|
UniqueArray [3]string `validate:"unique"` |
|
|
|
IPAddrv6 string `validate:"ip6_addr"` |
|
|
|
UniqueMap map[string]string `validate:"unique"` |
|
|
|
UinxAddr string `validate:"unix_addr"` // can't fail from within Go's net package currently, but maybe in the future
|
|
|
|
|
|
|
|
MAC string `validate:"mac"` |
|
|
|
|
|
|
|
IsColor string `validate:"iscolor"` |
|
|
|
|
|
|
|
StrPtrMinLen *string `validate:"min=10"` |
|
|
|
|
|
|
|
StrPtrMinLenSecond *string `validate:"min=2"` |
|
|
|
|
|
|
|
StrPtrMaxLen *string `validate:"max=1"` |
|
|
|
|
|
|
|
StrPtrLen *string `validate:"len=2"` |
|
|
|
|
|
|
|
StrPtrLenSecond *string `validate:"len=7"` |
|
|
|
|
|
|
|
StrPtrLt *string `validate:"lt=1"` |
|
|
|
|
|
|
|
StrPtrLte *string `validate:"lte=1"` |
|
|
|
|
|
|
|
StrPtrLteMultiple *string `validate:"lte=2"` |
|
|
|
|
|
|
|
StrPtrLteMultipleSecond *string `validate:"lte=7"` |
|
|
|
|
|
|
|
StrPtrGt *string `validate:"gt=10"` |
|
|
|
|
|
|
|
StrPtrGte *string `validate:"gte=10"` |
|
|
|
|
|
|
|
StrPtrGtSecond *string `validate:"gt=2"` |
|
|
|
|
|
|
|
StrPtrGteSecond *string `validate:"gte=2"` |
|
|
|
|
|
|
|
OneOfString string `validate:"oneof=red green"` |
|
|
|
|
|
|
|
OneOfInt int `validate:"oneof=5 63"` |
|
|
|
|
|
|
|
UniqueSlice []string `validate:"unique"` |
|
|
|
|
|
|
|
UniqueArray [3]string `validate:"unique"` |
|
|
|
|
|
|
|
UniqueMap map[string]string `validate:"unique"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var test Test |
|
|
|
var test Test |
|
|
@ -152,17 +172,23 @@ func TestTranslations(t *testing.T) { |
|
|
|
test.Inner.GteCSFieldString = "1234" |
|
|
|
test.Inner.GteCSFieldString = "1234" |
|
|
|
|
|
|
|
|
|
|
|
test.MaxString = "1234" |
|
|
|
test.MaxString = "1234" |
|
|
|
|
|
|
|
test.MaxStringSecond = "12345678" |
|
|
|
test.MaxNumber = 2000 |
|
|
|
test.MaxNumber = 2000 |
|
|
|
test.MaxMultiple = make([]string, 9) |
|
|
|
test.MaxMultiple = make([]string, 9) |
|
|
|
|
|
|
|
test.MaxMultipleSecond = make([]string, 3) |
|
|
|
|
|
|
|
|
|
|
|
test.LtString = "1234" |
|
|
|
test.LtString = "1234" |
|
|
|
|
|
|
|
test.LtStringSecond = "12345678" |
|
|
|
test.LtNumber = 6 |
|
|
|
test.LtNumber = 6 |
|
|
|
test.LtMultiple = make([]string, 3) |
|
|
|
test.LtMultiple = make([]string, 3) |
|
|
|
|
|
|
|
test.LtMultipleSecond = make([]string, 8) |
|
|
|
test.LtTime = time.Now().Add(time.Hour * 24) |
|
|
|
test.LtTime = time.Now().Add(time.Hour * 24) |
|
|
|
|
|
|
|
|
|
|
|
test.LteString = "1234" |
|
|
|
test.LteString = "1234" |
|
|
|
|
|
|
|
test.LteStringSecond = "12345678" |
|
|
|
test.LteNumber = 6 |
|
|
|
test.LteNumber = 6 |
|
|
|
test.LteMultiple = make([]string, 3) |
|
|
|
test.LteMultiple = make([]string, 3) |
|
|
|
|
|
|
|
test.LteMultipleSecond = make([]string, 8) |
|
|
|
test.LteTime = time.Now().Add(time.Hour * 24) |
|
|
|
test.LteTime = time.Now().Add(time.Hour * 24) |
|
|
|
|
|
|
|
|
|
|
|
test.LtFieldString = "12345" |
|
|
|
test.LtFieldString = "12345" |
|
|
@ -452,15 +478,23 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GteString", |
|
|
|
ns: "Test.GteString", |
|
|
|
expected: "GteString должен содержать минимум 3 символы", |
|
|
|
expected: "GteString должен содержать минимум 3 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.GteStringSecond", |
|
|
|
|
|
|
|
expected: "GteStringSecond должен содержать минимум 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GteNumber", |
|
|
|
ns: "Test.GteNumber", |
|
|
|
expected: "GteNumber должен быть больше или равно 5.56", |
|
|
|
expected: "GteNumber должен быть больше или равно 5,56", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GteMultiple", |
|
|
|
ns: "Test.GteMultiple", |
|
|
|
expected: "GteMultiple должен содержать минимум 2 элементы", |
|
|
|
expected: "GteMultiple должен содержать минимум 2 элемента", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.GteMultipleSecond", |
|
|
|
|
|
|
|
expected: "GteMultipleSecond должен содержать минимум 7 элементов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GteTime", |
|
|
|
ns: "Test.GteTime", |
|
|
@ -468,15 +502,23 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GtString", |
|
|
|
ns: "Test.GtString", |
|
|
|
expected: "GtString должен быть длиннее 3 символы", |
|
|
|
expected: "GtString должен быть длиннее 3 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.GtStringSecond", |
|
|
|
|
|
|
|
expected: "GtStringSecond должен быть длиннее 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GtNumber", |
|
|
|
ns: "Test.GtNumber", |
|
|
|
expected: "GtNumber должен быть больше 5.56", |
|
|
|
expected: "GtNumber должен быть больше 5,56", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GtMultiple", |
|
|
|
ns: "Test.GtMultiple", |
|
|
|
expected: "GtMultiple должен содержать более 2 элементы", |
|
|
|
expected: "GtMultiple должен содержать более 2 элементов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.GtMultipleSecond", |
|
|
|
|
|
|
|
expected: "GtMultipleSecond должен содержать более 7 элементов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.GtTime", |
|
|
|
ns: "Test.GtTime", |
|
|
@ -484,15 +526,23 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LteString", |
|
|
|
ns: "Test.LteString", |
|
|
|
expected: "LteString должен содержать максимум 3 символы", |
|
|
|
expected: "LteString должен содержать максимум 3 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LteStringSecond", |
|
|
|
|
|
|
|
expected: "LteStringSecond должен содержать максимум 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LteNumber", |
|
|
|
ns: "Test.LteNumber", |
|
|
|
expected: "LteNumber должен быть менее или равен 5.56", |
|
|
|
expected: "LteNumber должен быть менее или равен 5,56", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LteMultiple", |
|
|
|
ns: "Test.LteMultiple", |
|
|
|
expected: "LteMultiple должен содержать максимум 2 элементы", |
|
|
|
expected: "LteMultiple должен содержать максимум 2 элемента", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LteMultipleSecond", |
|
|
|
|
|
|
|
expected: "LteMultipleSecond должен содержать максимум 7 элементов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LteTime", |
|
|
|
ns: "Test.LteTime", |
|
|
@ -500,15 +550,23 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LtString", |
|
|
|
ns: "Test.LtString", |
|
|
|
expected: "LtString должен иметь менее 3 символы", |
|
|
|
expected: "LtString должен иметь менее 3 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LtStringSecond", |
|
|
|
|
|
|
|
expected: "LtStringSecond должен иметь менее 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LtNumber", |
|
|
|
ns: "Test.LtNumber", |
|
|
|
expected: "LtNumber должен быть менее 5.56", |
|
|
|
expected: "LtNumber должен быть менее 5,56", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LtMultiple", |
|
|
|
ns: "Test.LtMultiple", |
|
|
|
expected: "LtMultiple должен содержать менее 2 элементы", |
|
|
|
expected: "LtMultiple должен содержать менее 2 элементов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LtMultipleSecond", |
|
|
|
|
|
|
|
expected: "LtMultipleSecond должен содержать менее 7 элементов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LtTime", |
|
|
|
ns: "Test.LtTime", |
|
|
@ -540,27 +598,47 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MaxString", |
|
|
|
ns: "Test.MaxString", |
|
|
|
expected: "MaxString должен содержать максимум 3 символы", |
|
|
|
expected: "MaxString должен содержать максимум 3 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.MaxStringSecond", |
|
|
|
|
|
|
|
expected: "MaxStringSecond должен содержать максимум 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MaxNumber", |
|
|
|
ns: "Test.MaxNumber", |
|
|
|
expected: "MaxNumber должен быть меньше или равно 1,113.00", |
|
|
|
expected: "MaxNumber должен быть меньше или равно 1 113,00", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MaxMultiple", |
|
|
|
ns: "Test.MaxMultiple", |
|
|
|
expected: "MaxMultiple должен содержать максимум 7 элементы", |
|
|
|
expected: "MaxMultiple должен содержать максимум 7 элементов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.MaxMultipleSecond", |
|
|
|
|
|
|
|
expected: "MaxMultipleSecond должен содержать максимум 2 элемента", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MinString", |
|
|
|
ns: "Test.MinString", |
|
|
|
expected: "MinString должен содержать минимум 1 символ", |
|
|
|
expected: "MinString должен содержать минимум 1 символ", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.MinStringMultiple", |
|
|
|
|
|
|
|
expected: "MinStringMultiple должен содержать минимум 2 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.MinStringMultipleSecond", |
|
|
|
|
|
|
|
expected: "MinStringMultipleSecond должен содержать минимум 7 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MinNumber", |
|
|
|
ns: "Test.MinNumber", |
|
|
|
expected: "MinNumber должен быть больше или равно 1,113.00", |
|
|
|
expected: "MinNumber должен быть больше или равно 1 113,00", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.MinMultiple", |
|
|
|
ns: "Test.MinMultiple", |
|
|
|
expected: "MinMultiple должен содержать минимум 7 элементы", |
|
|
|
expected: "MinMultiple должен содержать минимум 7 элементов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.MinMultipleSecond", |
|
|
|
|
|
|
|
expected: "MinMultipleSecond должен содержать минимум 2 элемента", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LenString", |
|
|
|
ns: "Test.LenString", |
|
|
@ -568,11 +646,15 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LenNumber", |
|
|
|
ns: "Test.LenNumber", |
|
|
|
expected: "LenNumber должен быть равен 1,113.00", |
|
|
|
expected: "LenNumber должен быть равен 1 113,00", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.LenMultiple", |
|
|
|
ns: "Test.LenMultiple", |
|
|
|
expected: "LenMultiple должен содержать 7 элементы", |
|
|
|
expected: "LenMultiple должен содержать 7 элементов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.LenMultipleSecond", |
|
|
|
|
|
|
|
expected: "LenMultipleSecond должен содержать 2 элемента", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.RequiredString", |
|
|
|
ns: "Test.RequiredString", |
|
|
@ -588,7 +670,11 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrMinLen", |
|
|
|
ns: "Test.StrPtrMinLen", |
|
|
|
expected: "StrPtrMinLen должен содержать минимум 10 символы", |
|
|
|
expected: "StrPtrMinLen должен содержать минимум 10 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrMinLenSecond", |
|
|
|
|
|
|
|
expected: "StrPtrMinLenSecond должен содержать минимум 2 символа", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrMaxLen", |
|
|
|
ns: "Test.StrPtrMaxLen", |
|
|
@ -596,7 +682,11 @@ func TestTranslations(t *testing.T) { |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrLen", |
|
|
|
ns: "Test.StrPtrLen", |
|
|
|
expected: "StrPtrLen должен быть длиной в 2 символы", |
|
|
|
expected: "StrPtrLen должен быть длиной в 2 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrLenSecond", |
|
|
|
|
|
|
|
expected: "StrPtrLenSecond должен быть длиной в 7 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrLt", |
|
|
|
ns: "Test.StrPtrLt", |
|
|
@ -606,13 +696,29 @@ func TestTranslations(t *testing.T) { |
|
|
|
ns: "Test.StrPtrLte", |
|
|
|
ns: "Test.StrPtrLte", |
|
|
|
expected: "StrPtrLte должен содержать максимум 1 символ", |
|
|
|
expected: "StrPtrLte должен содержать максимум 1 символ", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrLteMultiple", |
|
|
|
|
|
|
|
expected: "StrPtrLteMultiple должен содержать максимум 2 символа", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrLteMultipleSecond", |
|
|
|
|
|
|
|
expected: "StrPtrLteMultipleSecond должен содержать максимум 7 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrGt", |
|
|
|
ns: "Test.StrPtrGt", |
|
|
|
expected: "StrPtrGt должен быть длиннее 10 символы", |
|
|
|
expected: "StrPtrGt должен быть длиннее 10 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrGtSecond", |
|
|
|
|
|
|
|
expected: "StrPtrGtSecond должен быть длиннее 2 символов", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.StrPtrGte", |
|
|
|
ns: "Test.StrPtrGte", |
|
|
|
expected: "StrPtrGte должен содержать минимум 10 символы", |
|
|
|
expected: "StrPtrGte должен содержать минимум 10 символов", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ns: "Test.StrPtrGteSecond", |
|
|
|
|
|
|
|
expected: "StrPtrGteSecond должен содержать минимум 2 символа", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ns: "Test.OneOfString", |
|
|
|
ns: "Test.OneOfString", |
|
|
|