Skip to content

Releases: bufbuild/protovalidate-java

v0.5.0

12 Dec 20:39
df11bf2
Compare
Choose a tag to compare

Breaking Change: The build.buf.protovalidate.ValidationResult.getViolations() method no longer returns a list of protobuf build.buf.validate.Violations messages, but a list of a new wrapper class, build.buf.protovalidate.Violation. In most cases, changing the import for Violation and calling the toProto() method of the violation is all that needs to be done:

     // Note that the import should also change from `build.buf.validate.Violation`
     // to `build.buf.protovalidate.Violation`.
     for (Violation violation : validator.validate(msg).getViolations()) {
-        System.out.println(violation.getConstraintId());
+        System.out.println(violation.toProto().getConstraintId());
     }

ValidationResult also has a toProto() method that returns the protobuf build.buf.validate.Violations message equivalent. This can be used to get a list of protobuf build.buf.validate.Violation messages, using the getViolationsList() getter of said message, as before.

+    List<build.buf.validate.Violation> violations = validator.validate(msg).getViolations();
-    List<build.buf.validate.Violation> violations = validator.validate(msg).toProto().getViolationsList();

The new build.buf.protovalidate.Violation class provides additional getters for in-memory information about the violation which cannot be serialized to the wire:

  • getFieldValue(): Returns the value of the field failing validation, if there is a field corresponding to the violation.
  • getRuleValue(): Returns the value of the rule failing validation, if there is a rule corresponding to the violation.

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 message User.newBuilder().setEmail("invalid").build(), getFieldValue().getValue() will return "invalid" and getRuleValue().getValue() will return true.

Some violations do not correspond directly to a field, such as a message constraint failure; in these cases, the return value of getFieldValue() will be null.

What's Changed

Full Changelog: v0.4.2...v0.5.0

v0.4.2

04 Oct 15:19
4dce6e6
Compare
Choose a tag to compare

What's Changed

  • Bump com.google.guava:guava from 33.3.0-jre to 33.3.1-jre by @dependabot in #190
  • Bump org.junit:junit-bom from 5.11.0 to 5.11.1 by @dependabot in #189
  • Bump build.buf:buf from 1.41.0 to 1.44.0 by @dependabot in #192
  • Bump com.google.protobuf:protobuf-java from 4.28.1 to 4.28.2 by @dependabot in #186

Full Changelog: v0.4.1...v0.4.2

v0.4.1

03 Oct 16:07
26dfd7f
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.4.0...v0.4.1

v0.4.0

26 Sep 19:42
7345e69
Compare
Choose a tag to compare

Adds support for custom predefined field constraints. See the protovalidate documentation for more information.

Updates protovalidate to v0.8.1. Note that this is a breaking change. You may need to make some adjustments to your code:

  • Code that imports build.buf.validate.ExpressionProto or build.buf.validate.priv.PrivateProto should now only import build.buf.validate.ValidateProto.
  • build.buf.validate.priv.PrivateProto.field was moved to build.buf.validate.ValidateProto.predefined

What's Changed

Full Changelog: v0.3.2...v0.4.0

v0.3.2

16 Sep 15:37
3e92af1
Compare
Choose a tag to compare

What's Changed

  • Login to the BSR for code generation by @pkwarren in #179
  • Bump build.buf:buf from 1.40.1 to 1.41.0 by @dependabot in #180
  • Bump com.google.errorprone:error_prone_core from 2.31.0 to 2.32.0 by @dependabot in #181
  • Bump org.projectnessie.cel:cel-bom from 0.5.0 to 0.5.1 by @dependabot in #183
  • Bump com.google.protobuf:protobuf-java from 4.28.0 to 4.28.1 by @dependabot in #182
  • Bump com.uber.nullaway:nullaway from 0.11.2 to 0.11.3 by @dependabot in #184

Full Changelog: v0.3.1...v0.3.2

v0.3.1

13 Sep 15:24
0e42d32
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.3.0...v0.3.1

v0.3.0

15 Aug 14:38
63a1c22
Compare
Choose a tag to compare

Note

This release updates protovalidate-java to use Protobuf Java v4+, which is not currently completely compatible with Protobuf Java v3 gencode. If you can not upgrade to Protobuf Java v4 currently, you should continue to use protovalidate-java v0.2.1 or lower for now. A future release of Protobuf Java v4.27.x should allow for an easier transition.

What's Changed

Full Changelog: v0.2.1...v0.3.0

v0.2.1

02 Apr 20:59
f8cb206
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.2.0...v0.2.1

v0.2.0

05 Mar 18:49
1445f7d
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.1.9...v0.2.0

v0.1.9

21 Dec 16:17
581067b
Compare
Choose a tag to compare

Bug fixes

  • Fix integer overflow bug in validation error message by @lyang in #75

Dependency updates

  • Bump com.uber.nullaway:nullaway from 0.10.16 to 0.10.17 by @dependabot in #66
  • Bump org.projectnessie.cel:cel-bom from 0.3.21 to 0.4.1 by @dependabot in #67
  • Bump protobuf from 3.25.0 to 3.25.1 by @dependabot in #65
  • Bump org.projectnessie.cel:cel-bom from 0.4.1 to 0.4.3 by @dependabot in #69
  • Bump actions/setup-java from 3 to 4 by @dependabot in #71
  • Bump com.uber.nullaway:nullaway from 0.10.17 to 0.10.18 by @dependabot in #72
  • Bump com.diffplug.spotless:spotless-plugin-gradle from 6.22.0 to 6.23.2 by @dependabot in #73
  • Bump com.diffplug.spotless:spotless-plugin-gradle from 6.23.2 to 6.23.3 by @dependabot in #74

New Contributors

  • @lyang made their first contribution in #75

Full Changelog: v0.1.8...v0.1.9