Skip to content

Commit 21e0136

Browse files
committed
Merge branch 'master' into add-support-to-tag-valid
2 parents 1cd3439 + 0540a5e commit 21e0136

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+239
-928
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ jobs:
3838
with:
3939
go-version: 1.24.x
4040
- name: golangci-lint
41-
uses: golangci/golangci-lint-action@v6
41+
uses: golangci/golangci-lint-action@v7
4242
with:
4343
version: latest

.golangci.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: "2"
2+
linters:
3+
default: all
4+
disable:
5+
- copyloopvar
6+
- cyclop
7+
- depguard
8+
- dogsled
9+
- dupl
10+
- dupword
11+
- err113
12+
- errorlint
13+
- exhaustive
14+
- exhaustruct
15+
- forbidigo
16+
- forcetypeassert
17+
- funlen
18+
- gochecknoglobals
19+
- gocognit
20+
- goconst
21+
- gocritic
22+
- gocyclo
23+
- godot
24+
- gosec
25+
- gosmopolitan
26+
- interfacebloat
27+
- intrange
28+
- ireturn
29+
- lll
30+
- maintidx
31+
- misspell
32+
- mnd
33+
- nakedret
34+
- nestif
35+
- nilnil
36+
- nlreturn
37+
- nonamedreturns
38+
- paralleltest
39+
- perfsprint
40+
- prealloc
41+
- recvcheck
42+
- revive
43+
- staticcheck
44+
- tagalign
45+
- tagliatelle
46+
- testpackage
47+
- thelper
48+
- tparallel
49+
- unparam
50+
- varnamelen
51+
- wrapcheck
52+
- wsl

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GOCMD=go
33
linters-install:
44
@golangci-lint --version >/dev/null 2>&1 || { \
55
echo "installing linting tools..."; \
6-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \
6+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v2.0.2; \
77
}
88

99
lint: linters-install

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package validator
22
=================
3-
<img align="right" src="logo.png">![Project status](https://img.shields.io/badge/version-10.25.0-green.svg)
3+
<img align="right" src="logo.png">[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/go-playground/validator)](https://github.com/go-playground/validator/releases)
44
[![Build Status](https://github.com/go-playground/validator/actions/workflows/workflow.yml/badge.svg)](https://github.com/go-playground/validator/actions)
55
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)

baked_in.go

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func parseOneOfParam2(s string) []string {
261261
oneofValsCacheRWLock.Lock()
262262
vals = splitParamsRegex().FindAllString(s, -1)
263263
for i := 0; i < len(vals); i++ {
264-
vals[i] = strings.Replace(vals[i], "'", "", -1)
264+
vals[i] = strings.ReplaceAll(vals[i], "'", "")
265265
}
266266
oneofValsCache[s] = vals
267267
oneofValsCacheRWLock.Unlock()
@@ -946,7 +946,6 @@ func isNeField(fl FieldLevel) bool {
946946
}
947947

948948
switch kind {
949-
950949
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
951950
return field.Int() != currentField.Int()
952951

@@ -967,7 +966,6 @@ func isNeField(fl FieldLevel) bool {
967966
fieldType := field.Type()
968967

969968
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
970-
971969
t := currentField.Interface().(time.Time)
972970
fieldTime := field.Interface().(time.Time)
973971

@@ -1006,7 +1004,6 @@ func isLteCrossStructField(fl FieldLevel) bool {
10061004
}
10071005

10081006
switch kind {
1009-
10101007
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
10111008
return field.Int() <= topField.Int()
10121009

@@ -1024,7 +1021,6 @@ func isLteCrossStructField(fl FieldLevel) bool {
10241021
fieldType := field.Type()
10251022

10261023
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1027-
10281024
fieldTime := field.Convert(timeType).Interface().(time.Time)
10291025
topTime := topField.Convert(timeType).Interface().(time.Time)
10301026

@@ -1053,7 +1049,6 @@ func isLtCrossStructField(fl FieldLevel) bool {
10531049
}
10541050

10551051
switch kind {
1056-
10571052
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
10581053
return field.Int() < topField.Int()
10591054

@@ -1071,7 +1066,6 @@ func isLtCrossStructField(fl FieldLevel) bool {
10711066
fieldType := field.Type()
10721067

10731068
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1074-
10751069
fieldTime := field.Convert(timeType).Interface().(time.Time)
10761070
topTime := topField.Convert(timeType).Interface().(time.Time)
10771071

@@ -1099,7 +1093,6 @@ func isGteCrossStructField(fl FieldLevel) bool {
10991093
}
11001094

11011095
switch kind {
1102-
11031096
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
11041097
return field.Int() >= topField.Int()
11051098

@@ -1117,7 +1110,6 @@ func isGteCrossStructField(fl FieldLevel) bool {
11171110
fieldType := field.Type()
11181111

11191112
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1120-
11211113
fieldTime := field.Convert(timeType).Interface().(time.Time)
11221114
topTime := topField.Convert(timeType).Interface().(time.Time)
11231115

@@ -1145,7 +1137,6 @@ func isGtCrossStructField(fl FieldLevel) bool {
11451137
}
11461138

11471139
switch kind {
1148-
11491140
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
11501141
return field.Int() > topField.Int()
11511142

@@ -1163,7 +1154,6 @@ func isGtCrossStructField(fl FieldLevel) bool {
11631154
fieldType := field.Type()
11641155

11651156
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1166-
11671157
fieldTime := field.Convert(timeType).Interface().(time.Time)
11681158
topTime := topField.Convert(timeType).Interface().(time.Time)
11691159

@@ -1191,7 +1181,6 @@ func isNeCrossStructField(fl FieldLevel) bool {
11911181
}
11921182

11931183
switch kind {
1194-
11951184
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
11961185
return topField.Int() != field.Int()
11971186

@@ -1212,7 +1201,6 @@ func isNeCrossStructField(fl FieldLevel) bool {
12121201
fieldType := field.Type()
12131202

12141203
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1215-
12161204
t := field.Convert(timeType).Interface().(time.Time)
12171205
fieldTime := topField.Convert(timeType).Interface().(time.Time)
12181206

@@ -1240,7 +1228,6 @@ func isEqCrossStructField(fl FieldLevel) bool {
12401228
}
12411229

12421230
switch kind {
1243-
12441231
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
12451232
return topField.Int() == field.Int()
12461233

@@ -1261,7 +1248,6 @@ func isEqCrossStructField(fl FieldLevel) bool {
12611248
fieldType := field.Type()
12621249

12631250
if fieldType.ConvertibleTo(timeType) && topField.Type().ConvertibleTo(timeType) {
1264-
12651251
t := field.Convert(timeType).Interface().(time.Time)
12661252
fieldTime := topField.Convert(timeType).Interface().(time.Time)
12671253

@@ -1289,7 +1275,6 @@ func isEqField(fl FieldLevel) bool {
12891275
}
12901276

12911277
switch kind {
1292-
12931278
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
12941279
return field.Int() == currentField.Int()
12951280

@@ -1310,7 +1295,6 @@ func isEqField(fl FieldLevel) bool {
13101295
fieldType := field.Type()
13111296

13121297
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
1313-
13141298
t := currentField.Convert(timeType).Interface().(time.Time)
13151299
fieldTime := field.Convert(timeType).Interface().(time.Time)
13161300

@@ -1333,7 +1317,6 @@ func isEq(fl FieldLevel) bool {
13331317
param := fl.Param()
13341318

13351319
switch field.Kind() {
1336-
13371320
case reflect.String:
13381321
return field.String() == param
13391322

@@ -1620,7 +1603,9 @@ func isImage(fl FieldLevel) bool {
16201603
if err != nil {
16211604
return false
16221605
}
1623-
defer file.Close()
1606+
defer func() {
1607+
_ = file.Close()
1608+
}()
16241609

16251610
mime, err := mimetype.DetectReader(file)
16261611
if err != nil {
@@ -1850,7 +1835,6 @@ func requireCheckFieldValue(
18501835
}
18511836

18521837
switch kind {
1853-
18541838
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
18551839
return field.Int() == asInt(value)
18561840

@@ -2059,7 +2043,6 @@ func isGteField(fl FieldLevel) bool {
20592043
}
20602044

20612045
switch kind {
2062-
20632046
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
20642047

20652048
return field.Int() >= currentField.Int()
@@ -2077,7 +2060,6 @@ func isGteField(fl FieldLevel) bool {
20772060
fieldType := field.Type()
20782061

20792062
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
2080-
20812063
t := currentField.Convert(timeType).Interface().(time.Time)
20822064
fieldTime := field.Convert(timeType).Interface().(time.Time)
20832065

@@ -2105,7 +2087,6 @@ func isGtField(fl FieldLevel) bool {
21052087
}
21062088

21072089
switch kind {
2108-
21092090
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
21102091

21112092
return field.Int() > currentField.Int()
@@ -2123,7 +2104,6 @@ func isGtField(fl FieldLevel) bool {
21232104
fieldType := field.Type()
21242105

21252106
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
2126-
21272107
t := currentField.Convert(timeType).Interface().(time.Time)
21282108
fieldTime := field.Convert(timeType).Interface().(time.Time)
21292109

@@ -2146,7 +2126,6 @@ func isGte(fl FieldLevel) bool {
21462126
param := fl.Param()
21472127

21482128
switch field.Kind() {
2149-
21502129
case reflect.String:
21512130
p := asInt(param)
21522131

@@ -2180,7 +2159,6 @@ func isGte(fl FieldLevel) bool {
21802159
case reflect.Struct:
21812160

21822161
if field.Type().ConvertibleTo(timeType) {
2183-
21842162
now := time.Now().UTC()
21852163
t := field.Convert(timeType).Interface().(time.Time)
21862164

@@ -2197,7 +2175,6 @@ func isGt(fl FieldLevel) bool {
21972175
param := fl.Param()
21982176

21992177
switch field.Kind() {
2200-
22012178
case reflect.String:
22022179
p := asInt(param)
22032180

@@ -2244,7 +2221,6 @@ func hasLengthOf(fl FieldLevel) bool {
22442221
param := fl.Param()
22452222

22462223
switch field.Kind() {
2247-
22482224
case reflect.String:
22492225
p := asInt(param)
22502226

@@ -2295,7 +2271,6 @@ func isLteField(fl FieldLevel) bool {
22952271
}
22962272

22972273
switch kind {
2298-
22992274
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
23002275

23012276
return field.Int() <= currentField.Int()
@@ -2313,7 +2288,6 @@ func isLteField(fl FieldLevel) bool {
23132288
fieldType := field.Type()
23142289

23152290
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
2316-
23172291
t := currentField.Convert(timeType).Interface().(time.Time)
23182292
fieldTime := field.Convert(timeType).Interface().(time.Time)
23192293

@@ -2341,7 +2315,6 @@ func isLtField(fl FieldLevel) bool {
23412315
}
23422316

23432317
switch kind {
2344-
23452318
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
23462319

23472320
return field.Int() < currentField.Int()
@@ -2359,7 +2332,6 @@ func isLtField(fl FieldLevel) bool {
23592332
fieldType := field.Type()
23602333

23612334
if fieldType.ConvertibleTo(timeType) && currentField.Type().ConvertibleTo(timeType) {
2362-
23632335
t := currentField.Convert(timeType).Interface().(time.Time)
23642336
fieldTime := field.Convert(timeType).Interface().(time.Time)
23652337

@@ -2382,7 +2354,6 @@ func isLte(fl FieldLevel) bool {
23822354
param := fl.Param()
23832355

23842356
switch field.Kind() {
2385-
23862357
case reflect.String:
23872358
p := asInt(param)
23882359

@@ -2416,7 +2387,6 @@ func isLte(fl FieldLevel) bool {
24162387
case reflect.Struct:
24172388

24182389
if field.Type().ConvertibleTo(timeType) {
2419-
24202390
now := time.Now().UTC()
24212391
t := field.Convert(timeType).Interface().(time.Time)
24222392

@@ -2433,7 +2403,6 @@ func isLt(fl FieldLevel) bool {
24332403
param := fl.Param()
24342404

24352405
switch field.Kind() {
2436-
24372406
case reflect.String:
24382407
p := asInt(param)
24392408

0 commit comments

Comments
 (0)