Skip to content

Commit f8036a5

Browse files
committed
fix(validators): redefinition of the built-in functions
1 parent 111c60e commit f8036a5

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

internal/parameter/validators/int.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ import (
66
"strconv"
77
)
88

9-
func Max(max int) func(string) error {
9+
func Max(maxVal int) func(string) error {
1010
return func(str string) error {
1111
v, err := strconv.Atoi(str)
1212
if err != nil {
1313
return errors.New("invalid integer")
1414
}
15-
if v > max {
16-
return fmt.Errorf("value must less than or equal to %d", max)
15+
if v > maxVal {
16+
return fmt.Errorf("value must less than or equal to %d", maxVal)
1717
}
1818
return nil
1919
}
2020
}
2121

22-
func Min(min int) func(string) error {
22+
func Min(minVal int) func(string) error {
2323
return func(str string) error {
2424
v, err := strconv.Atoi(str)
2525
if err != nil {
2626
return errors.New("invalid integer")
2727
}
28-
if v < min {
29-
return fmt.Errorf("value must less than or equal to %d", min)
28+
if v < minVal {
29+
return fmt.Errorf("value must less than or equal to %d", minVal)
3030
}
3131
return nil
3232
}

internal/parameter/validators/str.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ var (
1010
regexFQDN = regexp.MustCompile(`^([a-zA-Z0-9][a-zA-Z0-9-]{0,62})(\.[a-zA-Z0-9][a-zA-Z0-9-]{0,62})*?(\.[a-zA-Z][a-zA-Z0-9]{0,62})\.?$`)
1111
)
1212

13-
func MaxLength(max int) func(string) error {
13+
func MaxLength(maxLen int) func(string) error {
1414
return func(str string) error {
15-
if len(str) > max {
16-
return fmt.Errorf("string must be less than or equal to %d characters", max)
15+
if len(str) > maxLen {
16+
return fmt.Errorf("string must be less than or equal to %d characters", maxLen)
1717
}
1818
return nil
1919
}
2020
}
2121

22-
func MinLength(min int) func(string) error {
22+
func MinLength(minLen int) func(string) error {
2323
return func(str string) error {
24-
if len(str) < min {
25-
return fmt.Errorf("string must be greater than or equal to %d characters", min)
24+
if len(str) < minLen {
25+
return fmt.Errorf("string must be greater than or equal to %d characters", minLen)
2626
}
2727
return nil
2828
}

internal/parameter/validators/str_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func TestIPv6Validator(t *testing.T) {
7575
for _, v := range tests {
7676
err := IPv6Validator()(v.ip)
7777
if v.expected {
78-
assert.Equal(t)
7978
assert.NoError(t, err)
8079
} else {
8180
assert.Error(t, err)

0 commit comments

Comments
 (0)