@@ -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 }
@@ -2596,7 +2600,12 @@ func isUnixAddrResolvable(fl FieldLevel) bool {
25962600
25972601// isUnixDomainSocketExists is the validation function for validating if the field's value is an existing Unix domain socket.
25982602// It handles both filesystem-based sockets and Linux abstract sockets.
2603+ // It always returns false for Windows.
25992604func isUnixDomainSocketExists (fl FieldLevel ) bool {
2605+ if runtime .GOOS == "windows" {
2606+ return false
2607+ }
2608+
26002609 sockpath := fl .Field ().String ()
26012610
26022611 if sockpath == "" {
@@ -3092,8 +3101,8 @@ func isSpiceDB(fl FieldLevel) bool {
30923101func isCreditCard (fl FieldLevel ) bool {
30933102 val := fl .Field ().String ()
30943103 var creditCard bytes.Buffer
3095- segments := strings .SplitSeq (val , " " )
3096- for segment := range segments {
3104+ segments := strings .Split (val , " " )
3105+ for _ , segment := range segments {
30973106 if len (segment ) < 3 {
30983107 return false
30993108 }
@@ -3191,7 +3200,7 @@ func tryCallValidateFn(field reflect.Value, validateFn string) (bool, error) {
31913200 case reflect .Bool :
31923201 return firstReturnValue .Bool (), nil
31933202 case reflect .Interface :
3194- errorType := reflect .TypeFor [ error ] ()
3203+ errorType := reflect .TypeOf (( * error )( nil )). Elem ()
31953204
31963205 if firstReturnValue .Type ().Implements (errorType ) {
31973206 return firstReturnValue .IsNil (), nil
0 commit comments