1.0 update usage question
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- ドキュメント
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
調査の方向性
issue の GuestAddressTest の例から始め、ValidatorFactory のセットアップと、それによって検証される violation フィールドを確認してください。nullable プロパティと descriptor パスを含め、constraint とフィールドの詳細を調べるために 1.0 でサポートされている使用方法を特定して文書化してください。例では、期待される assertions を明確に示す必要があります。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 70
- フォーク
- 17
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 13
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bufbuild/protovalidate-java のほかの issue
-
Bug
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
bufbuild/protovalidate-java#379 · コメント 4 件 · リアクション 1 件 ·
-
Feature
bufbuild/protovalidate-java#80 · 担当者 1 名 ·
bufbuild/protovalidate-java の issue をすべて見る
似ている issue
-
area/plugin
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
kestra-io/plugin-kestra#190 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/rocketmq-dashboard#5064 ·