Skip to content

Commit 8850ea7

Browse files
committed
encoding/jsonschema: add test case for empty field
I noticed that empty fields were inadvertently missed from some property checks due to a flaw in the `patternProperties` logic. Add a test case for this case, to be fixed in a subsequent CL. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I32e8341edb3ee73cdcbfa406ff4d51b2ce634c66 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1203596 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 47c1559 commit 8850ea7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This tests the case where there's a patternProperties keyword
2+
# and no other fields.
3+
# TODO the empty-field test should fail but currently does not.
4+
5+
-- schema.json --
6+
{
7+
"$schema": "https://json-schema.org/draft/2020-12/schema",
8+
"type": "object",
9+
"patternProperties": {
10+
".*": {
11+
"type": "string"
12+
}
13+
}
14+
}
15+
-- out/decode/extract --
16+
@jsonschema(schema="https://json-schema.org/draft/2020-12/schema")
17+
18+
{[=~".*" & !~"^()$"]: string}
19+
...
20+
-- test/empty-field.json --
21+
{"": true}

0 commit comments

Comments
 (0)