Skip to content

Commit 632725e

Browse files
committed
slow validation example
1 parent 8b13fa4 commit 632725e

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

gen/tests/example/v1/validations_pb2.py

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/tests/example/v1/validations_pb2.pyi

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/tests/example/v1/validations.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ message Embed {
6363
message RepeatedEmbedSkip {
6464
repeated Embed val = 1 [(buf.validate.field).repeated.items.ignore = IGNORE_ALWAYS];
6565
}
66+
67+
message RepeatedItems {
68+
repeated int64 items = 1 [
69+
(buf.validate.field).repeated = {
70+
items: {
71+
int64: {gt: 0}
72+
}
73+
}
74+
];
75+
}

tests/validate_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@ def test_timestamp(self):
8383

8484
violations = protovalidate.collect_violations(msg)
8585
assert len(violations) == 0
86+
87+
def test_repeated_items(self):
88+
msg = validations_pb2.RepeatedItems(items=[i + 1 for i in range(2000)])
89+
protovalidate.validate(msg)
90+
91+
violations = protovalidate.collect_violations(msg)
92+
assert len(violations) == 0

0 commit comments

Comments
 (0)