Skip to content

Commit 27de2d7

Browse files
committed
$quote instruction
1 parent 8aa8b14 commit 27de2d7

File tree

7 files changed

+108
-30
lines changed

7 files changed

+108
-30
lines changed

instructions/$quote.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "$quote",
3+
"description": "use value without evaluation",
4+
"keywords": ["$quote"],
5+
"required": ["$quote"],
6+
"evaluate": {
7+
"keywords": [],
8+
"validatorKeyword": "eval$quote",
9+
"title": "use value",
10+
"description": "use value without evaluation"
11+
}
12+
}

instructions/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ module.exports = [
77
require('./$if.json'),
88
require('./$delay.json'),
99
require('./$func.json'),
10-
require('./$call.json')
10+
require('./$call.json'),
11+
require('./$quote.json')
1112
];

schema/evaluate.json

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"validateAsync": {
4040
"allOf": [
4141
{
42-
"description": "valdate evaluated instruction keywords",
42+
"description": "validate evaluated instruction keywords",
4343
"properties": {
4444
"$exec": {
4545
"type": "string",
@@ -95,7 +95,7 @@
9595
"validateAsync": {
9696
"allOf": [
9797
{
98-
"description": "valdate evaluated instruction keywords",
98+
"description": "validate evaluated instruction keywords",
9999
"properties": {
100100
"$ref": {
101101
"type": "string",
@@ -147,7 +147,7 @@
147147
"validateAsync": {
148148
"allOf": [
149149
{
150-
"description": "valdate evaluated instruction keywords",
150+
"description": "validate evaluated instruction keywords",
151151
"properties": {
152152
"$data": {
153153
"type": "string",
@@ -194,7 +194,7 @@
194194
"validateAsync": {
195195
"allOf": [
196196
{
197-
"description": "valdate evaluated instruction keywords",
197+
"description": "validate evaluated instruction keywords",
198198
"properties": {
199199
"$if": {
200200
"type": "boolean"
@@ -243,7 +243,7 @@
243243
"validateAsync": {
244244
"allOf": [
245245
{
246-
"description": "valdate evaluated instruction keywords",
246+
"description": "validate evaluated instruction keywords",
247247
"properties": {
248248
"$wait": {
249249
"type": "integer",
@@ -293,7 +293,7 @@
293293
"validateAsync": {
294294
"allOf": [
295295
{
296-
"description": "valdate evaluated instruction keywords",
296+
"description": "validate evaluated instruction keywords",
297297
"properties": {
298298
"$name": {
299299
"type": "string",
@@ -367,7 +367,7 @@
367367
"validateAsync": {
368368
"allOf": [
369369
{
370-
"description": "valdate evaluated instruction keywords",
370+
"description": "validate evaluated instruction keywords",
371371
"properties": {
372372
"$call": {
373373
"anyOf": [
@@ -400,6 +400,26 @@
400400
]
401401
}
402402
},
403+
{
404+
"if": {
405+
"required": [
406+
"$quote"
407+
]
408+
},
409+
"then": {
410+
"title": "instruction $quote",
411+
"allOf": [
412+
{
413+
"title": "execute instruction",
414+
"description": "executes supported script instructions",
415+
"validateAsync": {
416+
"description": "execute instruction using custom keyword",
417+
"eval$quote": true
418+
}
419+
}
420+
]
421+
}
422+
},
403423
{
404424
"then": {
405425
"title": "parallel execution",

schema/evaluate.json.dot

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,36 @@
6565
{
6666
"title": "instruction {{=inst.name}}",
6767
"allOf": [
68-
{
69-
"title": "evaluate properties",
70-
"description": "evaluates all or some keywords using this (full) schema, properties-scripts are replaced with returned synchronous or asynchronous value",
71-
{{? inst.evaluate.keywords }}
72-
"properties": {
73-
{{~ inst.evaluate.keywords:keyword:i }}
74-
{{?i}},{{?}}
75-
"{{=keyword}}": { "$ref": "#" }
76-
{{~}}
77-
}
78-
{{??}}
79-
"additionalProperties": { "$ref": "#" }
80-
{{?}}
81-
},
82-
{
83-
"title": "object to [async] value",
84-
"description": "Merge object properties into a single [asynchronous] object value",
85-
"objectToAsync": true
86-
},
68+
{{ var evalKeywords = inst.evaluate.keywords; }}
69+
{{? !evalKeywords || evalKeywords.length }}
70+
{
71+
"title": "evaluate properties",
72+
"description": "evaluates all or some keywords using this (full) schema, properties-scripts are replaced with returned synchronous or asynchronous value",
73+
{{? evalKeywords }}
74+
"properties": {
75+
{{~ evalKeywords:keyword:i }}
76+
{{?i}},{{?}}
77+
"{{=keyword}}": { "$ref": "#" }
78+
{{~}}
79+
}
80+
{{??}}
81+
"additionalProperties": { "$ref": "#" }
82+
{{?}}
83+
},
84+
{
85+
"title": "object to [async] value",
86+
"description": "Merge object properties into a single [asynchronous] object value",
87+
"objectToAsync": true
88+
},
89+
{{?}}
8790
{
8891
"title": "execute instruction",
8992
"description": "executes supported script instructions",
9093
"validateAsync": {
9194
{{? inst.schema }}
9295
"allOf": [
9396
{
94-
"description": "valdate evaluated instruction keywords",
97+
"description": "validate evaluated instruction keywords",
9598
"properties": {{= JSON.stringify(inst.schema) }}
9699
},
97100
{

schema/instruction.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
"properties": {
3535
"keywords": {
3636
"description": "keywords that should be evaluated before validator keyword is called. If this property is absent, all keywords will be evaluated (in parallel)",
37-
"allOf": [
38-
{ "$ref": "#keywordsArray" }
37+
"anyOf": [
38+
{ "$ref": "#keywordsArray" },
39+
{ "$ref": "#emptyArray" }
3940
]
4041
},
4142
"validatorKeyword": {
@@ -74,6 +75,11 @@
7475
"items": { "$ref": "#scriptKeyword" },
7576
"minItems": 1,
7677
"uniqueItems": true
78+
},
79+
"emptyArray": {
80+
"id": "#emptyArray",
81+
"type": "array",
82+
"maxItems": 0
7783
}
7884
}
7985
}

schema/schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
{
2626
"$ref": "#$call"
2727
},
28+
{
29+
"$ref": "#$quote"
30+
},
2831
{
2932
"$ref": "#parallel"
3033
},
@@ -166,6 +169,21 @@
166169
"$call"
167170
]
168171
},
172+
"_$quote": {
173+
"id": "#$quote",
174+
"title": "$quote",
175+
"description": "use value without evaluation",
176+
"type": "object",
177+
"properties": {
178+
"$quote": {
179+
"$ref": "#"
180+
}
181+
},
182+
"additionalProperties": false,
183+
"required": [
184+
"$quote"
185+
]
186+
},
169187
"parallel": {
170188
"id": "#parallel",
171189
"description": "scripts in the object are executed in parallel, property names should not start with $",

schema/schema_strict.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
{
2626
"$ref": "#$call"
2727
},
28+
{
29+
"$ref": "#$quote"
30+
},
2831
{
2932
"$ref": "#parallel"
3033
},
@@ -312,6 +315,21 @@
312315
"$call"
313316
]
314317
},
318+
"_$quote": {
319+
"id": "#$quote",
320+
"title": "$quote",
321+
"description": "use value without evaluation",
322+
"type": "object",
323+
"properties": {
324+
"$quote": {
325+
"$ref": "#"
326+
}
327+
},
328+
"additionalProperties": false,
329+
"required": [
330+
"$quote"
331+
]
332+
},
315333
"parallel": {
316334
"id": "#parallel",
317335
"description": "scripts in the object are executed in parallel, property names should not start with $",

0 commit comments

Comments
 (0)