diff --git a/core/mapping/marshaler.go b/core/mapping/marshaler.go index 797cbdf26..b2c89b7bf 100644 --- a/core/mapping/marshaler.go +++ b/core/mapping/marshaler.go @@ -3,6 +3,7 @@ package mapping import ( "fmt" "reflect" + "slices" "strings" ) @@ -152,18 +153,10 @@ func validateOptional(field reflect.StructField, value reflect.Value) error { } func validateOptions(value reflect.Value, opt *fieldOptions) error { - var found bool val := fmt.Sprint(value.Interface()) - for i := range opt.Options { - if opt.Options[i] == val { - found = true - break - } - } - if !found { + if !slices.Contains(opt.Options, val) { return fmt.Errorf("field %q not in options", val) } - return nil }