{"record":{"id":"0388344df2e86a16","repo":"go-playground/validator","slug":"bad-field-type-s-s","errorCode":null,"errorMessage":"Bad field type %s:%s","messagePattern":"Bad field type (.+?):(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baked_in.go","lineNumber":484,"sourceCode":"\t\t\t}\n\n\t\t\tif _, ok := seen[key]; ok {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tseen[key] = struct{}{}\n\t\t}\n\n\t\treturn true\n\n\tdefault:\n\t\tif parent := fl.Parent(); parent.Kind() == reflect.Struct {\n\t\t\tuniqueField := parent.FieldByName(param)\n\t\t\tif !uniqueField.IsValid() {\n\t\t\t\tpanic(fmt.Sprintf(\"Bad field name provided %s\", param))\n\t\t\t}\n\n\t\t\tif uniqueField.Kind() != field.Kind() {\n\t\t\t\tpanic(fmt.Sprintf(\"Bad field type %s:%s\", field.Type(), uniqueField.Type()))\n\t\t\t}\n\n\t\t\treturn getValue(field) != getValue(uniqueField)\n\t\t}\n\n\t\tpanic(fmt.Sprintf(\"Bad field type %s\", field.Type()))\n\t}\n}\n\n// isMAC is the validation function for validating if the field's value is a valid MAC address.\nfunc isMAC(fl FieldLevel) bool {\n\t_, err := net.ParseMAC(fl.Field().String())\n\n\treturn err == nil\n}\n\n// isCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address.\nfunc isCIDRv4(fl FieldLevel) bool {","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/go-playground/validator/blob/facf128d2eecf42bd4ff447adc961aa21bb64aed/baked_in.go#L466-L502","documentation":"Panics inside isUnique's default branch when the sibling field named by the unique tag parameter exists but its reflect.Kind differs from the field being validated. unique performs a direct value comparison between the two fields, which is only meaningful for like kinds; the panic message prints both types (field type : unique field type) to expose the mismatch.","triggerScenarios":"Thrown at baked_in.go:484 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make both fields the same type so the comparison is valid","Convert one field's type to match the other (e.g. int32 vs int64, or one side a pointer)","Write a custom validator if cross-type uniqueness comparison is genuinely needed"],"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"}