Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit f100fde

Browse files
committed
feat: implement schema for var
1 parent e741320 commit f100fde

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

schemas/json-logic.json

+52-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,55 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
3-
"$id": "http://jsonlogic.com/schemas/json-logic.json"
3+
"$id": "http://jsonlogic.com/schemas/json-logic.json",
4+
5+
"definitions": {
6+
"get": {
7+
"oneOf": [
8+
{
9+
"type": "string",
10+
"title": "Property",
11+
"description": "The key passed to var can use dot-notation to get the property of a property (to any depth you need):"
12+
},
13+
{
14+
"type": "number",
15+
"title": "Index",
16+
"description": "You can also use the var operator to access an array by numeric index."
17+
}
18+
]
19+
}
20+
},
21+
22+
"title": "var",
23+
"description": "Retrieve data from the provided data object.",
24+
"type": "object",
25+
"additionalProperties": false,
26+
"required": ["var"],
27+
"properties": {
28+
"var": {
29+
"oneOf": [
30+
{
31+
"type": "array",
32+
"items": [
33+
{ "$ref": "#/definitions/get" },
34+
{
35+
"type": ["array", "boolean", "null", "number", "object", "string"],
36+
"title": "Default",
37+
"description": "You can supply a default, as the second argument, for values that might be missing in the data object."
38+
}
39+
]
40+
},
41+
{
42+
"$ref": "#/definitions/get",
43+
"title": "Shortcut",
44+
"description": "If you like, we support syntactic sugar to skip the array around single arguments."
45+
},
46+
{
47+
"type": "string",
48+
"enum": [""],
49+
"title": "Entire data object",
50+
"description": "You can also use var with an empty string to get the entire data object – which is really useful in map, filter, and reduce rules."
51+
}
52+
]
53+
}
54+
}
455
}

0 commit comments

Comments
 (0)