Validator generator [WiP] - #10200
Closed
stephanos wants to merge 10 commits into
Closed
Conversation
stephanos
force-pushed
the
stephanos/protobuf-validate-gen
branch
6 times, most recently
from
May 8, 2026 02:43
0fc7732 to
e10b967
Compare
stephanos
commented
May 8, 2026
| "go.uber.org/fx" | ||
| ) | ||
|
|
||
| type ValidatorsSuite struct { |
Contributor
Author
There was a problem hiding this comment.
This test detects if a validator has a missing field validator.
stephanos
force-pushed
the
stephanos/protobuf-validate-gen
branch
5 times, most recently
from
May 8, 2026 02:49
637a3c3 to
c42f6af
Compare
long-nt-tran
self-requested a review
May 8, 2026 18:46
long-nt-tran
force-pushed
the
stephanos/protobuf-validate-gen
branch
4 times, most recently
from
June 2, 2026 16:43
298af06 to
aa2af8f
Compare
long-nt-tran
force-pushed
the
stephanos/protobuf-validate-gen
branch
from
July 13, 2026 22:22
aa2af8f to
fc4fbf2
Compare
stephanos
added a commit
that referenced
this pull request
Jul 14, 2026
Replace the presence-only, predicate-based validator with the typed design from PR #10200: - api/protohelpers/validation: FieldValidator[T,V] func(*T, fieldName, V) error + Field/Optional/NestedFieldValidator helpers, a ValidatorRegistry for type-based dispatch, and an fx Module. Testify-free (prod-safe). - Generated api/protohelpers/validate now emits a typed <Msg>FieldValidators struct (one FieldValidator per field), ValidateAndNormalize (invokes each in order, can mutate for normalization), and RegisterValidator. Field validators receive the parent message (cross-field checks) and typed value; every field must be assigned (nil panics), preserving exhaustiveness. - Matcher keeps the thin predicate vocabulary; validator no longer shares it. The two now share only the field model + exhaustiveness. Frontend StartWorkflowExecution uses the typed validator (non-preempting: message-presence required, fields with specific downstream errors Optional). Also: activity_test example now omits every field with a testvar default, relying on env.Requests() defaults; eager suite asserts the response with the generated matcher. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
long-nt-tran
force-pushed
the
stephanos/protobuf-validate-gen
branch
from
July 14, 2026 15:24
fc4fbf2 to
fdda0b6
Compare
long-nt-tran
force-pushed
the
stephanos/protobuf-validate-gen
branch
2 times, most recently
from
July 23, 2026 16:23
01d700b to
d1fb599
Compare
The nested ValidateAndNormalize now takes a fieldPrefix string so sub-field errors render as "user_metadata.summary" rather than just "summary". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Drop `req *T` from NestedFieldValidator signature; the parent context
is never needed since namespace is already passed explicitly.
- Add NoOp[T,V]() and NestedNoOp[T,V]() helpers to replace verbose
inline no-op closures throughout validator.go.
- Generator auto-wires nested proto types: fields whose Go type matches
a `nested:` entry are emitted as an embedded `{prefix}FieldValidators`
struct and their ValidateAndNormalize call is forwarded automatically,
removing the hand-written bridging closure in validator.go.
- Regenerate validator_gen.go to reflect all of the above.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
long-nt-tran
force-pushed
the
stephanos/protobuf-validate-gen
branch
from
August 13, 2026 01:34
48f3f26 to
415452d
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Opt-in validator that exhaustively validate all protobuf fields in 1 place.
Why?
Adds semantic validation for protobufs as a thin layer before the proto request reaches actual business logic.
How did you test it?