feat: update validation logic
ci/woodpecker/push/govulncheck Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details

This commit is contained in:
Dawid Wysokiński 2024-03-06 08:20:10 +01:00
parent 6ffc1f4ce4
commit b0f1a3d1bd
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
6 changed files with 6 additions and 36 deletions

View File

@ -875,7 +875,7 @@ func (params *ListPlayersParams) Names() []string {
}
const (
playerNamesMinLength = 1
playerNamesMinLength = 0
playerNamesMaxLength = 100
)

View File

@ -674,21 +674,6 @@ func TestListPlayersParams_SetNames(t *testing.T) {
},
},
},
{
name: "ERR: len(names) < 1",
args: args{
names: nil,
},
expectedErr: domain.ValidationError{
Model: "ListPlayersParams",
Field: "names",
Err: domain.LenOutOfRangeError{
Min: 1,
Max: 100,
Current: 0,
},
},
},
{
name: "ERR: len(names) > 100",
args: args{
@ -704,7 +689,7 @@ func TestListPlayersParams_SetNames(t *testing.T) {
Model: "ListPlayersParams",
Field: "names",
Err: domain.LenOutOfRangeError{
Min: 1,
Min: 0,
Max: 100,
Current: 101,
},

View File

@ -810,7 +810,7 @@ func (params *ListTribesParams) Tags() []string {
}
const (
tribeTagsMinLength = 1
tribeTagsMinLength = 0
tribeTagsMaxLength = 100
)

View File

@ -614,21 +614,6 @@ func TestListTribesParams_SetTags(t *testing.T) {
},
},
},
{
name: "ERR: len(tags) < 1",
args: args{
tags: nil,
},
expectedErr: domain.ValidationError{
Model: "ListTribesParams",
Field: "tags",
Err: domain.LenOutOfRangeError{
Min: 1,
Max: 100,
Current: 0,
},
},
},
{
name: "ERR: len(tags) > 100",
args: args{
@ -644,7 +629,7 @@ func TestListTribesParams_SetTags(t *testing.T) {
Model: "ListTribesParams",
Field: "tags",
Err: domain.LenOutOfRangeError{
Min: 1,
Min: 0,
Max: 100,
Current: 101,
},

View File

@ -583,7 +583,7 @@ func TestListPlayers(t *testing.T) {
// body
body := decodeJSON[apimodel.ErrorResponse](t, resp.Body)
domainErr := domain.LenOutOfRangeError{
Min: 1,
Min: 0,
Max: 100,
Current: len(req.URL.Query()["name"]),
}

View File

@ -583,7 +583,7 @@ func TestListTribes(t *testing.T) {
// body
body := decodeJSON[apimodel.ErrorResponse](t, resp.Body)
domainErr := domain.LenOutOfRangeError{
Min: 1,
Min: 0,
Max: 100,
Current: len(req.URL.Query()["tag"]),
}