validation-gen: better check explicit opt-in/out

Rather than ONLY checking the SecondClosest comments, we can check the
type's real comments, too.
This commit is contained in:
Tim Hockin committed 2026-07-08 09:55:49 -07:00
1 parent 27a383487e
commit eaf1fa198c
1 file changed
+6
@@ -334,10 +334,16 @@ func GetTargets(context *generator.Context, args *Args) []generator.Target {
}
shouldCreateObjectValidationFn := func(t *types.Type) bool {
// opt-out
if checkMainTag(t.CommentLines, "false") {
return false
}
if checkMainTag(t.SecondClosestCommentLines, "false") {
return false
}
// opt-in
if checkMainTag(t.CommentLines, "true") {
return true
}
if checkMainTag(t.SecondClosestCommentLines, "true") {
return true
}