Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

1.0 update usage question

Open
#362 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
java, kotlin

Research direction

Start with the GuestAddressTest example in the issue and review the ValidatorFactory setup and violation fields it exercises. Determine and document the supported 1.0 usage for inspecting constraint and field details, including the nullable properties and descriptor paths; the example should clearly show the expected assertions.

Written by the indexing model from the issue text.

Description

I'm updating to the 1.0 version of protovalidate-java, and there's a breaking change in how I consume the violations that I'm confused by.

Given this sample message:

message GuesAAddress {
  optional string zip_code = 1 [
    (buf.validate.field).required = true,
    (buf.validate.field).string.len = 5
  ];
}

I guessed at the changes I needed to make to unit test this.

 package common.guest.v1
 
-import build.buf.protovalidate.Validator
+import build.buf.protovalidate.ValidatorFactory
@@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test
 
 class GuestAddressTest {
 
-    private val validator = Validator()
+    private val validator = ValidatorFactory.newBuilder().build()
 
     @Test
     fun `validate guest address - field wrong length`() {
@@ -24,8 +24,8 @@ class GuestAddressTest {
 
         result.violations.size shouldBe 1
         assertSoftly(result.violations[0]) {
-            constraintId shouldBe "string.len"
-            fieldPath shouldBe "zip_code"
+            fieldValue?.descriptor?.fullName shouldBe "common.guest.v1.GuestAddress.zip_code"
+            ruleValue?.descriptor?.fullName shouldBe "buf.validate.StringRules.len"
         }
     }
 }

Is what I did the expected usage change, or is there a cleaner way to inspect the fields? Them being nullable felt odd, and the path to get to those fields was not obvious to me.

Appreciate it - thanks.

Dominant language
Java
Stars
70
Forks
17
Avg merge
2d 13h
Merged PRs (30d)
13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bufbuild/protovalidate-java

All issues in bufbuild/protovalidate-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.