1.0 update usage question
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- api, developer-experience
Hướng nghiên cứu
Bắt đầu với ví dụ GuestAddressTest trong issue và xem xét thiết lập ValidatorFactory cùng các trường violation mà nó kiểm tra. Xác định và ghi lại cách sử dụng được hỗ trợ trong 1.0 để kiểm tra chi tiết constraint và trường, bao gồm các thuộc tính nullable và các đường dẫn descriptor; ví dụ phải thể hiện rõ các assertions dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 70
- Fork
- 17
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 13
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bufbuild/protovalidate-java
-
Bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
bufbuild/protovalidate-java#379 · 4 bình luận · 1 reaction ·
-
Feature
bufbuild/protovalidate-java#80 · 1 người được giao ·
Tất cả issue của bufbuild/protovalidate-java
Issue tương tự
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Đang mởarea/plugin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Add canonical URLs and a sitemap Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/rocketmq-dashboard#5064 ·