-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/jsonschema: support
minContains
and maxContains
keywords
This change add support for JSON Schema `minContains` and `maxContains` keywords. Change-Id: I4e27444e212d36adc120918386db54aaae3d98fc Signed-off-by: haoqixu <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199615 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,45 @@ | ||
-- schema.yaml -- | ||
$schema: "https://json-schema.org/draft/2019-09/schema" | ||
type: object | ||
|
||
properties: | ||
p1: | ||
type: array | ||
contains: {} | ||
|
||
p2: | ||
type: array | ||
contains: {} | ||
minContains: 0 | ||
|
||
p3: | ||
type: array | ||
contains: {} | ||
maxContains: 6 | ||
|
||
p4: | ||
type: array | ||
contains: {} | ||
minContains: 3 | ||
maxContains: 6 | ||
|
||
# If "contains" is not present within the same schema object, then this keyword has no effect. | ||
p5: | ||
type: array | ||
minContains: 6 | ||
p6: | ||
type: array | ||
maxContains: 6 | ||
|
||
additionalProperties: false | ||
|
||
-- out/decode/extract -- | ||
import "list" | ||
|
||
@jsonschema(schema="https://json-schema.org/draft/2019-09/schema") | ||
p1?: list.MatchN(>=1, _) | ||
p2?: list.MatchN(>=0, _) | ||
p3?: list.MatchN(>=1 & <=6, _) | ||
p4?: list.MatchN(>=3 & <=6, _) | ||
p5?: [...] | ||
p6?: [...] |