feat: integrate buf/validate (protovalidate) for field-level validation#378
Open
feat: integrate buf/validate (protovalidate) for field-level validation#378
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #378 +/- ##
==========================================
+ Coverage 73.93% 74.01% +0.08%
==========================================
Files 87 87
Lines 8670 8706 +36
==========================================
+ Hits 6410 6444 +34
- Misses 1700 1701 +1
- Partials 560 561 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Integrate buf/validate (protovalidate) to support field-level validation rules in generated proto files and configuration generation.
Changes
Core Features
field_validateproperty toFieldProp, enabling proto field-level constraints (e.g.,string:{min_len:1 max_len:20},int32:{gt:0 lte:100}) viabuf.validate.fieldoption.message_validateproperty toFieldProp, supporting CEL-based message-level constraints (e.g., cross-field validation likethis.value <= 0 || this.name != '') viabuf.validate.messageoption.Validatecolumn in@TABLEAUmetasheet, supporting CEL-based worksheet-level constraints viabuf.validate.messageoption on the top-level message.cel_expressionas a shorthand for simple CEL expressions (e.g.,this.start_time < this.end_time), powered by upgradingbuf.build/go/protovalidateto v1.1.0.Implementation Details
validatefield toFieldPropintableau.proto, andvalidatefield toMetasheetOptionsinmetabook.proto.internal/protogen/exporter.goto generatebuf.validate.fieldandbuf.validate.messageoptions in proto output.internal/protogen/field_prop.goto parsefield_validateandmessage_validateproperties.internal/confgen/util.goto handlebuf/validate/validate.protoimport path resolution.buf/validate/validate.prototo the proto compiler's well-known import paths.Testing
Validate#ValidateFieldLevel.csv,Validate#ValidateMessageLevel.csv,Validate#ValidateWorksheetLevel.csvwith corresponding@TABLEAU.csvmetasheet.exporter_test.goandutil_test.go.Other
go.moddependencies includingbuf.build/go/protovalidatev1.1.0.Bug Fixes (drive-by)
confgen.go: usesheetNameinstead of undefinedspecifiedSheetNamein error context.parser.go: remove redundantfmt.Sprintfwrapping insidexerrors.Newf.