go-playground/validator · critical

validateFn is not supported with 'no-validate-fn' tag

Error message

validateFn is not supported with 'no-validate-fn' tag

What it means

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.

Source

Thrown at validate_fn.go:6

//go:build validator_novalidatefn

package validator

func isValidateFn(fl FieldLevel) bool {
	panic("validateFn is not supported with 'no-validate-fn' tag")
}

View on GitHub (pinned to facf128d2e)

Solutions

  1. Rebuild/redeploy the binary without the `validator_novalidatefn` build tag: go build (no tags).
  2. Remove all validateFn tag usages from structs if the stripped build must be kept.
  3. Guard the feature with build-tag-separated code paths so stripped builds never construct structs using validateFn.
  4. Add a startup smoke test that validates a sample struct using validateFn so a mis-tagged build fails immediately.
  5. Document the build-tag constraint wherever the tag-based build is configured (Makefile, CI).

Example fix

// before (Makefile)
go build -tags validator_novalidatefn -o app ./cmd/app

// after
go build -o app ./cmd/app  # validateFn tag in use, drop the stripped build
Defensive patterns

Strategy: validation

Validate before calling

// At startup, only when building with the stripped tag:
//go:build validator_novalidatefn

func AssertValidateFnUnused() {
    for _, f := range structsWithValidateFn {
        panic("validateFn used but binary built with validator_novalidatefn: " + f)
    }
}

Try / catch

func safeValidate(v *validator.Validate, s interface{}) (err error) {
    defer func() {
        if r := recover(); r != nil {
            if strings.Contains(fmt.Sprint(r), "no-validate-fn") {
                err = errors.New("binary lacks validateFn support; rebuild without validator_novalidatefn")
                return
            }
            panic(r)
        }
    }()
    return v.Struct(s)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of go-playground/validator@facf128d2e (2026-09-02). Data as JSON: /api/errors/8cafc0deb51a8c13. Report an issue: GitHub.