{"record":{"id":"85036d38a3fbd2b5","repo":"go-playground/validator","slug":"bad-param-number-for-skip-unless-s","errorCode":null,"errorMessage":"Bad param number for skip_unless %s","messagePattern":"Bad param number for skip_unless (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baked_in.go","lineNumber":2179,"sourceCode":"\tparams := parseOneOfParam2(fl.Param())\n\tif len(params)%2 != 0 {\n\t\tpanic(fmt.Sprintf(\"Bad param number for required_unless %s\", fl.FieldName()))\n\t}\n\n\tfor i := 0; i < len(params); i += 2 {\n\t\tif requireCheckFieldValue(fl, params[i], params[i+1], false) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn hasValue(fl)\n}\n\n// skipUnless is the validation function\n// The field under validation must be present and not empty only unless all the other specified fields are equal to the value following with the specified field.\nfunc skipUnless(fl FieldLevel) bool {\n\tparams := parseOneOfParam2(fl.Param())\n\tif len(params)%2 != 0 {\n\t\tpanic(fmt.Sprintf(\"Bad param number for skip_unless %s\", fl.FieldName()))\n\t}\n\tfor i := 0; i < len(params); i += 2 {\n\t\tif !requireCheckFieldValue(fl, params[i], params[i+1], false) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn hasValue(fl)\n}\n\n// excludedUnless is the validation function\n// The field under validation must not be present or is empty unless all the other specified fields are equal to the value following with the specified field.\nfunc excludedUnless(fl FieldLevel) bool {\n\tparams := parseOneOfParam2(fl.Param())\n\tif len(params)%2 != 0 {\n\t\tpanic(fmt.Sprintf(\"Bad param number for excluded_unless %s\", fl.FieldName()))\n\t}\n\tfor i := 0; i < len(params); i += 2 {\n\t\tif requireCheckFieldValue(fl, params[i], params[i+1], false) {","sourceCodeStart":2161,"sourceCodeEnd":2197,"githubUrl":"https://github.com/go-playground/validator/blob/facf128d2eecf42bd4ff447adc961aa21bb64aed/baked_in.go#L2161-L2197","documentation":"skip_unless skips requiring the field unless all listed field,value conditions fail... its params must be field,value pairs; an odd count after parseOneOfParam2 panics at baked_in.go:2179 with 'Bad param number for skip_unless'.","triggerScenarios":"Tag like `skip_unless=Mode` or `skip_unless=A,1,B` — incomplete field,value pair (odd param count), including cases where a value containing a comma distorts the split.","commonSituations":"Missing comparison value in a hand-written tag; mixing up parameter conventions with skip_use/skip_without style tags; programmatic tag generation bugs.","solutions":["Supply pairs: `skip_unless=Mode,advanced`.","Check for stray commas in values; escape or restructure.","Confirm the intended tag family (skip_unless vs required_unless/excluded_unless all share the pair rule).","Add a regression test for the tag string."],"exampleFix":"// before\nMode string\nNote string `validate:\"skip_unless=Mode\"`\n\n// after\nMode string\nNote string `validate:\"skip_unless=Mode,basic\"`","handlingStrategy":"validation","validationCode":"func checkSkipUnlessTag(tagValue string) error {\n    parts := strings.Split(tagValue, \",\")\n    if len(parts)%2 != 0 {\n        return fmt.Errorf(\"skip_unless needs field,value pairs; got %d params in %q\", len(parts), tagValue)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"func safeValidate(v *Validate, s interface{}) (err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"validator panic (check skip_unless params): %v\", r)\n        }\n    }()\n    return v.Struct(s)\n}","preventionTips":["Provide complete field,value pairs for skip_unless","Keep the same pair convention across all *_if/*_unless conditional tags","Escape commas in values","Unit-test the tag string against Validate.Struct"],"tags":["go","validator","panic","struct-tags","skip-unless"],"backgroundTag":"invalid-validator-tag-params","analyzedSha":"facf128d2eecf42bd4ff447adc961aa21bb64aed","analyzedAt":"2026-09-02T10:19:04.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}