Skip to content

Commit ac33a23

Browse files
Dean KarnDean Karn
authored andcommitted
Merge pull request #113 from bluesuncorp/v5-development
update string comparisons to use utf8.RuneCountInString
2 parents 06aac46 + 8a9bd75 commit ac33a23

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

baked_in.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ func isGte(top interface{}, current interface{}, field interface{}, param string
592592
case reflect.String:
593593
p := asInt(param)
594594

595-
return int64(len(st.String())) >= p
595+
return int64(utf8.RuneCountInString(st.String())) >= p
596596

597597
case reflect.Slice, reflect.Map, reflect.Array:
598598
p := asInt(param)
@@ -637,7 +637,7 @@ func isGt(top interface{}, current interface{}, field interface{}, param string)
637637
case reflect.String:
638638
p := asInt(param)
639639

640-
return int64(len(st.String())) > p
640+
return int64(utf8.RuneCountInString(st.String())) > p
641641

642642
case reflect.Slice, reflect.Map, reflect.Array:
643643
p := asInt(param)
@@ -681,7 +681,7 @@ func hasLengthOf(top interface{}, current interface{}, field interface{}, param
681681
case reflect.String:
682682
p := asInt(param)
683683

684-
return int64(len(st.String())) == p
684+
return int64(utf8.RuneCountInString(st.String())) == p
685685

686686
case reflect.Slice, reflect.Map, reflect.Array:
687687
p := asInt(param)
@@ -875,7 +875,7 @@ func isLte(top interface{}, current interface{}, field interface{}, param string
875875
case reflect.String:
876876
p := asInt(param)
877877

878-
return int64(len(st.String())) <= p
878+
return int64(utf8.RuneCountInString(st.String())) <= p
879879

880880
case reflect.Slice, reflect.Map, reflect.Array:
881881
p := asInt(param)
@@ -920,7 +920,7 @@ func isLt(top interface{}, current interface{}, field interface{}, param string)
920920
case reflect.String:
921921
p := asInt(param)
922922

923-
return int64(len(st.String())) < p
923+
return int64(utf8.RuneCountInString(st.String())) < p
924924

925925
case reflect.Slice, reflect.Map, reflect.Array:
926926
p := asInt(param)

0 commit comments

Comments
 (0)