Skip to content

Commit 89dc794

Browse files
committed
[upd] revert irrelevant changes
1 parent 59d7a4a commit 89dc794

File tree

32 files changed

+374
-331
lines changed

32 files changed

+374
-331
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ linters:
5252
- varnamelen
5353
- wrapcheck
5454
- wsl
55+
- modernize

baked_in.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"os"
1818
"reflect"
1919
"runtime"
20-
"slices"
2120
"strconv"
2221
"strings"
2322
"sync"
@@ -305,7 +304,12 @@ func isOneOf(fl FieldLevel) bool {
305304
default:
306305
panic(fmt.Sprintf("Bad field type %s", field.Type()))
307306
}
308-
return slices.Contains(vals, v)
307+
for i := 0; i < len(vals); i++ {
308+
if vals[i] == v {
309+
return true
310+
}
311+
}
312+
return false
309313
}
310314

311315
// isOneOfCI is the validation function for validating if the current field's value is one of the provided string values (case insensitive).
@@ -653,7 +657,7 @@ func isISBN13(fl FieldLevel) bool {
653657

654658
factor := []int32{1, 3}
655659

656-
for i = range int32(12) {
660+
for i = 0; i < 12; i++ {
657661
checksum += factor[i%2] * int32(s[i]-'0')
658662
}
659663

@@ -671,7 +675,7 @@ func isISBN10(fl FieldLevel) bool {
671675
var checksum int32
672676
var i int32
673677

674-
for i = range int32(9) {
678+
for i = 0; i < 9; i++ {
675679
checksum += (i + 1) * int32(s[i]-'0')
676680
}
677681

@@ -696,7 +700,7 @@ func isISSN(fl FieldLevel) bool {
696700
pos := 8
697701
checksum := 0
698702

699-
for i := range 7 {
703+
for i := 0; i < 7; i++ {
700704
checksum += pos * int(s[i]-'0')
701705
pos--
702706
}
@@ -828,7 +832,7 @@ func isBitcoinBech32Address(fl FieldLevel) bool {
828832
b := p >> 25
829833
p = (p&0x1ffffff)<<5 ^ v
830834

831-
for i := range 5 {
835+
for i := 0; i < 5; i++ {
832836
if (b>>uint(i))&1 == 1 {
833837
p ^= GEN[i]
834838
}
@@ -3097,8 +3101,8 @@ func isSpiceDB(fl FieldLevel) bool {
30973101
func isCreditCard(fl FieldLevel) bool {
30983102
val := fl.Field().String()
30993103
var creditCard bytes.Buffer
3100-
segments := strings.SplitSeq(val, " ")
3101-
for segment := range segments {
3104+
segments := strings.Split(val, " ")
3105+
for _, segment := range segments {
31023106
if len(segment) < 3 {
31033107
return false
31043108
}
@@ -3196,7 +3200,7 @@ func tryCallValidateFn(field reflect.Value, validateFn string) (bool, error) {
31963200
case reflect.Bool:
31973201
return firstReturnValue.Bool(), nil
31983202
case reflect.Interface:
3199-
errorType := reflect.TypeFor[error]()
3203+
errorType := reflect.TypeOf((*error)(nil)).Elem()
32003204

32013205
if firstReturnValue.Type().Implements(errorType) {
32023206
return firstReturnValue.IsNil(), nil

0 commit comments

Comments
 (0)