go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.14k stars 1.29k forks source link

comparison tag for string #1177

Open 1298509345 opened 9 months ago

1298509345 commented 9 months ago

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

why the comparison tag for string is len(str) why not return str1 >= str2

Code sample, to showcase or reproduce:

baked_in.go
func isGteField(fl FieldLevel) bool {
    field := fl.Field()
    kind := field.Kind()

    currentField, currentKind, ok := fl.GetStructFieldOK()
    if !ok || currentKind != kind {
        return false
    }

    switch kind {
                // ... 
    }

    // default reflect.String // what does this annotation mean
    return len(field.String()) >= len(currentField.String())
}