{"record":{"id":"700d419c6c77a913","repo":"go-playground/validator","slug":"bad-field-type-s","errorCode":null,"errorMessage":"Bad field type %s","messagePattern":"Bad field type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baked_in.go","lineNumber":342,"sourceCode":"func isHTML(fl FieldLevel) bool {\n\treturn hTMLRegex().MatchString(fl.Field().String())\n}\n\nfunc isOneOf(fl FieldLevel) bool {\n\tvals := parseOneOfParam2(fl.Param())\n\n\tfield := fl.Field()\n\n\tvar v string\n\tswitch field.Kind() {\n\tcase reflect.String:\n\t\tv = field.String()\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:\n\t\tv = strconv.FormatInt(field.Int(), 10)\n\tcase reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:\n\t\tv = strconv.FormatUint(field.Uint(), 10)\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Bad field type %s\", field.Type()))\n\t}\n\n\treturn slices.Contains(vals, v)\n}\n\n// isOneOfCI is the validation function for validating if the current field's value is one of the provided string values (case insensitive).\nfunc isOneOfCI(fl FieldLevel) bool {\n\tvals := parseOneOfParam2(fl.Param())\n\tfield := fl.Field()\n\n\tif field.Kind() != reflect.String {\n\t\tpanic(fmt.Sprintf(\"Bad field type %s\", field.Type()))\n\t}\n\n\treturn slices.ContainsFunc(vals, func(val string) bool {\n\t\treturn strings.EqualFold(val, field.String())\n\t})\n}","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/go-playground/validator/blob/facf128d2eecf42bd4ff447adc961aa21bb64aed/baked_in.go#L324-L360","documentation":"Panics inside the isOneOf (oneof) validator when the field's kind is not supported. oneof compares the field value against the parameter list as a decimal string, which only works for string kinds and signed/unsigned integers; any other kind (floats, bools, slices, structs) cannot be stringified this way, so the guard panics naming the offending field type. It also propagates to the inverse isNoneOf tag, which calls isOneOf.","triggerScenarios":"Thrown at baked_in.go:342 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only use oneof on string or integer-typed fields","For numeric types not supported, compare via a custom registered validator","For float fields, use a custom validator or convert the field to a supported type","Add unit tests asserting the field kind before tagging with oneof"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"facf128d2eecf42bd4ff447adc961aa21bb64aed","analyzedAt":"2026-09-02T10:19:04.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}