{"record":{"id":"0e77062a66b7bb4a","repo":"go-playground/validator","slug":"undefined-validation-function-s-on-field-s","errorCode":null,"errorMessage":"Undefined validation function '%s' on field '%s'","messagePattern":"Undefined validation function '(.+?)' on field '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cache.go","lineNumber":311,"sourceCode":"\t\t\t\t\taliasFirst, aliasLast := v.parseFieldTagsRecursive(aliasTag, fieldName, current.tag, true)\n\n\t\t\t\t\tcurrent.tag = aliasFirst.tag\n\t\t\t\t\tcurrent.fn = aliasFirst.fn\n\t\t\t\t\tcurrent.runValidationWhenNil = aliasFirst.runValidationWhenNil\n\t\t\t\t\tcurrent.hasParam = aliasFirst.hasParam\n\t\t\t\t\tcurrent.param = aliasFirst.param\n\t\t\t\t\tcurrent.typeof = aliasFirst.typeof\n\t\t\t\t\tcurrent.hasAlias = true\n\n\t\t\t\t\tif aliasFirst.next != nil {\n\t\t\t\t\t\tnextInChain := current.next\n\t\t\t\t\t\tcurrent.next = aliasFirst.next\n\t\t\t\t\t\taliasLast.next = nextInChain\n\t\t\t\t\t\taliasLast.isBlockEnd = false\n\t\t\t\t\t\tcurrent = aliasLast\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpanic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, current.tag, fieldName)))\n\t\t\t\t}\n\n\t\t\t\tif len(orVals) > 1 {\n\t\t\t\t\tcurrent.typeof = typeOr\n\t\t\t\t}\n\n\t\t\t\tif len(vals) > 1 {\n\t\t\t\t\tcurrent.param = strings.ReplaceAll(strings.ReplaceAll(vals[1], utf8HexComma, \",\"), utf8Pipe, \"|\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrent.isBlockEnd = true\n\t\t}\n\t}\n\treturn\n}\n\nfunc (v *Validate) fetchCacheTag(tag string) *cTag {\n\t// find cached tag","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/go-playground/validator/blob/facf128d2eecf42bd4ff447adc961aa21bb64aed/cache.go#L293-L329","documentation":"This panic occurs during struct tag parsing (cache.go:311) when a validation tag used on a struct field is not registered in the validator's tag registry and is not a known alias. The library compiles tags into cached execution plans the first time a type is validated; any unknown tag name hits the else branch and panics with `undefinedValidation`. It is a fail-fast panic because an unrecognized tag means the validation expression cannot be compiled.","triggerScenarios":"Calling validate.Struct() (or Var) on a struct whose tag references a misspelled or non-existent validator (e.g. `validate:\"required,emial\"`); using a custom validator tag without calling RegisterValidation first; using an alias without RegisterAlias; a typo introduced by refactoring tags; passing a tag containing a stray character that splits it into an unknown tag.","commonSituations":"Typo in a struct tag; forgetting to register a custom validator on a newly created Validate instance (a second instance that lacks registrations the first had); upgrading validator/v10 where a tag was renamed or removed; copying tags between projects where custom tags were registered in package init; defining an alias that itself expands to an unknown tag.","solutions":["Fix the tag spelling on the offending struct field so it matches a baked-in validator (required, email, min, oneof, etc.).","Register the custom function before validating: v.RegisterValidation(\"mytag\", myFunc) — do this for every Validate instance you create.","If using shorthand, call v.RegisterAlias(alias, tags) before validation.","Check whether the tag was renamed in a validator/v10 upgrade by consulting the README tag table.","Find the failing field from the panic message ('on field %s') and inspect its tag at that struct location."],"exampleFix":"// before\ntype User struct {\n    Email string `validate:\"required,emial\"` // typo\n}\n\n// after\ntype User struct {\n    Email string `validate:\"required,email\"`\n}\n// or for a custom tag:\n// v.RegisterValidation(\"mytag\", myFunc) before v.Struct(user)","handlingStrategy":"validation","validationCode":"func checkTags(v *validator.Validate, samples ...interface{}) {\n    for _, s := range samples {\n        defer func() {\n            if r := recover(); r != nil {\n                panic(fmt.Sprintf(\"bad tag at startup: %v\", r))\n            }\n        }()\n        _ = v.Struct(s) // exercise each type once at boot\n    }\n}","typeGuard":null,"tryCatchPattern":"func safeValidate(v *validator.Validate, s interface{}) (err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"tag configuration panic: %v\", r)\n        }\n    }()\n    return v.Struct(s)\n}","preventionTips":["Register every custom validator and alias in package init on every Validate instance.","Keep a startup test that validates one instance of each annotated struct.","Verify tag names against the README tag table when upgrading validator/v10.","Use an editor plugin or linter that flags unknown struct tag names."],"tags":["go","validator","struct-tags","panic","unknown-tag"],"backgroundTag":"unknown-validation-tag","analyzedSha":"facf128d2eecf42bd4ff447adc961aa21bb64aed","analyzedAt":"2026-09-02T10:19:04.986Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}