1.0 update usage question
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
- Domain
- api, developer-experience
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bufbuild/protovalidate-java
-
Bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
bufbuild/protovalidate-java#379 · 4 comments · 1 reaction ·
-
Feature
bufbuild/protovalidate-java#80 · 1 assignee ·
All issues in bufbuild/protovalidate-java
Similar issues
-
area/plugin
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kestra-io/plugin-kestra#190 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/rocketmq-dashboard#5064 ·