{"record":{"id":"8cafc0deb51a8c13","repo":"go-playground/validator","slug":"validatefn-is-not-supported-with-no-validate-fn","errorCode":null,"errorMessage":"validateFn is not supported with 'no-validate-fn' tag","messagePattern":"validateFn is not supported with 'no-validate-fn' tag","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"validate_fn.go","lineNumber":6,"sourceCode":"//go:build validator_novalidatefn\n\npackage validator\n\nfunc isValidateFn(fl FieldLevel) bool {\n\tpanic(\"validateFn is not supported with 'no-validate-fn' tag\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":8,"githubUrl":"https://github.com/go-playground/validator/blob/facf128d2eecf42bd4ff447adc961aa21bb64aed/validate_fn.go#L1-L8","documentation":"validate_fn.go:6 is compiled only under the `validator_novalidatefn` build tag; in that build the isValidateFn hook unconditionally panics because the ValidateFn tag feature is stripped out. This binary was built with `-tags validator_novalidatefn`, so any struct field using the validateFn tag (or a custom validation function hook) will panic instead of validating.","triggerScenarios":"Running a binary compiled with `go build -tags validator_novalidatefn` and validating a struct whose field tag invokes the validateFn tag; calling a registered validation that routes through isValidateFn; enabling the stripped build for size reduction and then shipping code that still uses the feature.","commonSituations":"Deployment pipelines that add the novalidatefn build tag (e.g. to exclude reflection-heavy function hooks) while application structs still reference validateFn; a dependency compiled with the tag being reused in an app that uses the feature; teams switching build tags between environments and forgetting the feature is disabled.","solutions":["Rebuild/redeploy the binary without the `validator_novalidatefn` build tag: go build (no tags).","Remove all validateFn tag usages from structs if the stripped build must be kept.","Guard the feature with build-tag-separated code paths so stripped builds never construct structs using validateFn.","Add a startup smoke test that validates a sample struct using validateFn so a mis-tagged build fails immediately.","Document the build-tag constraint wherever the tag-based build is configured (Makefile, CI)."],"exampleFix":"// before (Makefile)\ngo build -tags validator_novalidatefn -o app ./cmd/app\n\n// after\ngo build -o app ./cmd/app  # validateFn tag in use, drop the stripped build","handlingStrategy":"validation","validationCode":"// At startup, only when building with the stripped tag:\n//go:build validator_novalidatefn\n\nfunc AssertValidateFnUnused() {\n    for _, f := range structsWithValidateFn {\n        panic(\"validateFn used but binary built with validator_novalidatefn: \" + f)\n    }\n}","typeGuard":null,"tryCatchPattern":"func safeValidate(v *validator.Validate, s interface{}) (err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            if strings.Contains(fmt.Sprint(r), \"no-validate-fn\") {\n                err = errors.New(\"binary lacks validateFn support; rebuild without validator_novalidatefn\")\n                return\n            }\n            panic(r)\n        }\n    }()\n    return v.Struct(s)\n}","preventionTips":["Keep build tags in sync with feature usage: grep for validateFn whenever the stripped build is enabled.","Add a CI job that builds both with and without validator_novalidatefn and runs the test suite.","Document the disabled feature wherever the build tag is set.","Run a startup smoke test validating a representative struct."],"tags":["go","validator","build-tags","panic","compile-time"],"backgroundTag":"feature-disabled-build-tag","analyzedSha":"facf128d2eecf42bd4ff447adc961aa21bb64aed","analyzedAt":"2026-09-02T10:19:04.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}