Releases: bufbuild/protovalidate-go
v0.8.0
Breaking Change: The protovalidate.ValidationError
type is no longer a protobuf buf.validate.Violations
message alias, but a struct containing a slice of protovalidate.Violation
instances. In most cases, accessing the Proto
member of the violation is all that needs to be done:
for _, violation := range err.Violations {
- fmt.Println(violation.GetMessage())
+ fmt.Println(violation.Proto.GetMessage())
}
protovalidate.ValidationError
still has a ToProto()
method that returns the protobuf buf.validate.Violations
message equivalent.
The new protovalidate.Violation
structure contains additional in-memory information about the violation which cannot be serialized to the wire:
FieldValue
: Aprotoreflect.Value
containing the value of the field failing validation, if there is a field corresponding to the violation.FieldDescriptor
: Aprotoreflect.FieldDescriptor
corresponding to the field failing validation.RuleValue
: Aprotoreflect.Value
containing the value of the rule failing validation, if there is a rule corresponding to the violation.RuleDescriptor
: Aprotoreflect.FieldDescriptor
corresponding to the rule failing validation.
Take, for example, the following protobuf message schema:
message User {
string email = 1 [(buf.validate.field).string.email = true];
}
If you try to validate the struct pb.User{Email: "invalid"}
, the FieldValue
will be "invalid"
and the RuleValue
will be true
.
Some violations do not correspond directly to a field, such as a message constraint failure; in these cases, the FieldValue
will be an invalid value and the FieldDescriptor
will be nil
.
What's Changed
- Implement structured field and rule paths, add field and rule values to ValidationErrors by @jchadwick-buf in #154
- Bump the go group with 2 updates by @dependabot in #161
Full Changelog: v0.7.3...v0.8.0
v0.7.3
What's Changed
- Add ResolvePredefinedConstraints method to DefaultResolver by @jchadwick-buf in #151
- Fix repeated predefined rule on repeated field by @jchadwick-buf in #150
Full Changelog: v0.7.2...v0.7.3
v0.7.2
v0.7.1
v0.7.0
What's Changed
-
Implement predefined field constraints by @jchadwick-buf in #144
NOTE: This is a breaking change. You will need to update code using the
validate.Violation
structure, as the fields now use explicit field presence.
Full Changelog: v0.6.5...v0.7.0
v0.6.5
What's Changed
- Add
buf.gen.yaml
v2 schema example by @milas in #138 - Upgrade to support Go 1.23 by @rodaine in #139
- Remove Go 1.20 support by @rodaine in #140
- Bugfix: avoid spurious tautology pruning when dealing with certain recursive messages by @rodaine in #142
New Contributors
Full Changelog: v0.6.4...v0.6.5
v0.6.4
This release adds support for Protobuf Editions features.
What's Changed
- Always treat groups as message fields by @jchadwick-buf in #132
Full Changelog: v0.6.3...v0.6.4
v0.6.3
What's Changed
- Improvement to unique implementation by @pkwarren in #128
- Export lib type by @oliversun9 in #130
Full Changelog: v0.6.2...v0.6.3
v0.6.2
v0.6.1
What's Changed
- Update license years and fix makefile by @pkwarren in #102
- DRY up ignore related conditionals by @rodaine in #103
- Bump the go group with 1 update by @dependabot in #106
- Bump the go group with 3 updates by @dependabot in #109
- Bump Go min version to 1.20 by @jhump in #110
- Update README.md by @rodaine in #111
- Add tuuid conformance tests by @rodaine in #114
- Add generate check CI step by @rodaine in #115
New Contributors
Full Changelog: v0.6.0...v0.6.1