@remoteoss/json-schema-form 0.11.11-dev.20250220174843 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/.vscode/settings.json +51 -0
- package/README.md +29 -24
- package/babel.config.mjs +14 -0
- package/eslint.config.mjs +3 -0
- package/jest.config.mjs +52 -0
- package/package.json +27 -71
- package/src/form.ts +3 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +24 -0
- package/test/form.test.ts +11 -0
- package/tsconfig.json +13 -0
- package/tsup.config.json +10 -0
- package/CHANGELOG.md +0 -320
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -2171
- package/dist/index.js +0 -2140
- package/dist/standalone.js +0 -13656
- package/json-schema-form.d.ts +0 -175
- package/json-schema-form.schema.json +0 -188
- package/src/tests/checkIfConditionMatches.test.js +0 -65
- package/src/tests/conditions.test.js +0 -938
- package/src/tests/const.test.js +0 -236
- package/src/tests/createHeadlessForm.customValidations.test.js +0 -803
- package/src/tests/createHeadlessForm.test.js +0 -4324
- package/src/tests/helpers.custom.js +0 -222
- package/src/tests/helpers.js +0 -2385
- package/src/tests/internals.helpers.test.js +0 -175
- package/src/tests/jsonLogic.fixtures.js +0 -986
- package/src/tests/jsonLogic.test.js +0 -588
- package/src/tests/modify.test.js +0 -939
- package/src/tests/testUtils.js +0 -11
- package/src/tests/utils.test.jsx +0 -32
|
@@ -1,986 +0,0 @@
|
|
|
1
|
-
export function createSchemaWithRulesOnFieldA(rules) {
|
|
2
|
-
return {
|
|
3
|
-
properties: {
|
|
4
|
-
field_a: {
|
|
5
|
-
type: 'number',
|
|
6
|
-
'x-jsf-logic-validations': Object.keys(rules),
|
|
7
|
-
},
|
|
8
|
-
field_b: {
|
|
9
|
-
type: 'number',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
required: ['field_a', 'field_b'],
|
|
13
|
-
'x-jsf-logic': { validations: rules },
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function createSchemaWithThreePropertiesWithRuleOnFieldA(rules) {
|
|
18
|
-
return {
|
|
19
|
-
properties: {
|
|
20
|
-
field_a: {
|
|
21
|
-
type: 'number',
|
|
22
|
-
'x-jsf-logic-validations': Object.keys(rules),
|
|
23
|
-
},
|
|
24
|
-
field_b: {
|
|
25
|
-
type: 'number',
|
|
26
|
-
},
|
|
27
|
-
field_c: {
|
|
28
|
-
type: 'number',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
'x-jsf-logic': { validations: rules },
|
|
32
|
-
required: ['field_a', 'field_b', 'field_c'],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const schemaWithNonRequiredField = {
|
|
37
|
-
properties: {
|
|
38
|
-
field_a: {
|
|
39
|
-
type: 'number',
|
|
40
|
-
},
|
|
41
|
-
field_b: {
|
|
42
|
-
type: 'number',
|
|
43
|
-
'x-jsf-logic-validations': ['a_greater_than_field_b'],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
'x-jsf-logic': {
|
|
47
|
-
validations: {
|
|
48
|
-
a_greater_than_field_b: {
|
|
49
|
-
errorMessage: 'Must be greater than field_a',
|
|
50
|
-
rule: {
|
|
51
|
-
'>': [{ var: 'field_a' }, { var: 'field_b' }],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
required: [],
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const schemaWithNativeAndJSONLogicChecks = {
|
|
60
|
-
properties: {
|
|
61
|
-
field_a: {
|
|
62
|
-
type: 'number',
|
|
63
|
-
minimum: 100,
|
|
64
|
-
'x-jsf-logic-validations': ['a_multiple_of_ten'],
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
'x-jsf-logic': {
|
|
68
|
-
validations: {
|
|
69
|
-
a_multiple_of_ten: {
|
|
70
|
-
errorMessage: 'Must be a multiple of 10',
|
|
71
|
-
rule: {
|
|
72
|
-
'===': [{ '%': [{ var: 'field_a' }, 10] }, 0],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
required: ['field_a'],
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export const schemaWithMissingRule = {
|
|
81
|
-
properties: {
|
|
82
|
-
field_a: {
|
|
83
|
-
type: 'number',
|
|
84
|
-
'x-jsf-logic-validations': ['a_greater_than_ten'],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
'x-jsf-logic': {
|
|
88
|
-
validations: {
|
|
89
|
-
a_greater_than_ten: {
|
|
90
|
-
errorMessage: 'Must be greater than 10',
|
|
91
|
-
// rule: { '>': [{ var: 'field_a' }, 10] }, this missing causes test to fail.
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
required: [],
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const schemaWithUnknownVariableInValidations = {
|
|
99
|
-
properties: {
|
|
100
|
-
// field_a: { type: 'number' }, this missing causes test to fail.
|
|
101
|
-
},
|
|
102
|
-
'x-jsf-logic': {
|
|
103
|
-
validations: {
|
|
104
|
-
a_equals_ten: {
|
|
105
|
-
errorMessage: 'Must equal 10',
|
|
106
|
-
rule: { '===': [{ var: 'field_a' }, 10] },
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const schemaWithUnknownVariableInComputedValues = {
|
|
113
|
-
properties: {
|
|
114
|
-
// field_a: { type: 'number' }, this missing causes test to fail.
|
|
115
|
-
},
|
|
116
|
-
'x-jsf-logic': {
|
|
117
|
-
computedValues: {
|
|
118
|
-
a_times_ten: {
|
|
119
|
-
rule: { '*': [{ var: 'field_a' }, 10] },
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const schemaWithMissingComputedValue = {
|
|
126
|
-
properties: {
|
|
127
|
-
field_a: {
|
|
128
|
-
type: 'number',
|
|
129
|
-
'x-jsf-logic-computedAttrs': {
|
|
130
|
-
title: '{{a_plus_ten}}',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
'x-jsf-logic': {
|
|
135
|
-
computedValues: {
|
|
136
|
-
a_plus_ten: {
|
|
137
|
-
// rule: { '+': [{ var: 'field_a' }, 10 ]} this missing causes test to fail.
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
required: [],
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const multiRuleSchema = {
|
|
145
|
-
properties: {
|
|
146
|
-
field_a: {
|
|
147
|
-
type: 'number',
|
|
148
|
-
'x-jsf-logic-validations': ['a_bigger_than_b', 'is_even_number'],
|
|
149
|
-
},
|
|
150
|
-
field_b: {
|
|
151
|
-
type: 'number',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
required: ['field_a', 'field_b'],
|
|
155
|
-
'x-jsf-logic': {
|
|
156
|
-
validations: {
|
|
157
|
-
a_bigger_than_b: {
|
|
158
|
-
errorMessage: 'A must be bigger than B',
|
|
159
|
-
rule: {
|
|
160
|
-
'>': [{ var: 'field_a' }, { var: 'field_b' }],
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
is_even_number: {
|
|
164
|
-
errorMessage: 'A must be even',
|
|
165
|
-
rule: {
|
|
166
|
-
'===': [{ '%': [{ var: 'field_a' }, 2] }, 0],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
export const schemaWithTwoRules = {
|
|
174
|
-
properties: {
|
|
175
|
-
field_a: {
|
|
176
|
-
type: 'number',
|
|
177
|
-
'x-jsf-logic-validations': ['a_bigger_than_b'],
|
|
178
|
-
},
|
|
179
|
-
field_b: {
|
|
180
|
-
type: 'number',
|
|
181
|
-
'x-jsf-logic-validations': ['is_even_number'],
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
required: ['field_a', 'field_b'],
|
|
185
|
-
'x-jsf-logic': {
|
|
186
|
-
validations: {
|
|
187
|
-
a_bigger_than_b: {
|
|
188
|
-
errorMessage: 'A must be bigger than B',
|
|
189
|
-
rule: {
|
|
190
|
-
'>': [{ var: 'field_a' }, { var: 'field_b' }],
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
is_even_number: {
|
|
194
|
-
errorMessage: 'B must be even',
|
|
195
|
-
rule: {
|
|
196
|
-
'===': [{ '%': [{ var: 'field_b' }, 2] }, 0],
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export const schemaWithComputedAttributes = {
|
|
204
|
-
properties: {
|
|
205
|
-
field_a: {
|
|
206
|
-
type: 'number',
|
|
207
|
-
},
|
|
208
|
-
field_b: {
|
|
209
|
-
type: 'number',
|
|
210
|
-
'x-jsf-logic-computedAttrs': {
|
|
211
|
-
title: 'This is {{a_times_two}}!',
|
|
212
|
-
const: 'a_times_two',
|
|
213
|
-
default: 'a_times_two',
|
|
214
|
-
description: 'This field is 2 times bigger than field_a with value of {{a_times_two}}.',
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
required: ['field_a', 'field_b'],
|
|
219
|
-
'x-jsf-logic': {
|
|
220
|
-
computedValues: {
|
|
221
|
-
a_times_two: {
|
|
222
|
-
rule: {
|
|
223
|
-
'*': [{ var: 'field_a' }, 2],
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const badSchemaThatWillNotSetAForcedValue = {
|
|
231
|
-
properties: {
|
|
232
|
-
field_a: {
|
|
233
|
-
type: 'number',
|
|
234
|
-
},
|
|
235
|
-
field_b: {
|
|
236
|
-
type: 'number',
|
|
237
|
-
'x-jsf-logic-computedAttrs': {
|
|
238
|
-
const: 'a_times_three',
|
|
239
|
-
default: 'a_times_two',
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
'x-jsf-logic': {
|
|
244
|
-
computedValues: {
|
|
245
|
-
a_times_two: {
|
|
246
|
-
rule: {
|
|
247
|
-
'*': [{ var: 'field_a' }, 2],
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
a_times_three: {
|
|
251
|
-
rule: {
|
|
252
|
-
'*': [{ var: 'field_a' }, 3],
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export const schemaWithInlineRuleForComputedAttributeWithoutCopy = {
|
|
260
|
-
properties: {
|
|
261
|
-
field_a: {
|
|
262
|
-
type: 'number',
|
|
263
|
-
},
|
|
264
|
-
field_b: {
|
|
265
|
-
type: 'number',
|
|
266
|
-
'x-jsf-logic-computedAttrs': {
|
|
267
|
-
title: {
|
|
268
|
-
rule: {
|
|
269
|
-
'+': [{ var: 'field_a' }, 10],
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export const schemaWithComputedAttributeThatDoesntExist = {
|
|
278
|
-
properties: {
|
|
279
|
-
field_a: {
|
|
280
|
-
type: 'number',
|
|
281
|
-
'x-jsf-logic-computedAttrs': {
|
|
282
|
-
minimum: 'iDontExist',
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
// x-jsf-logic: { computedValues: { iDontExist: { rule: 10 }} this missing causes test to fail.
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
export const schemaWithInlinedRuleOnComputedAttributeThatReferencesUnknownVar = {
|
|
290
|
-
properties: {
|
|
291
|
-
// iDontExist: { type: 'number' } this missing causes test to fail.
|
|
292
|
-
field_a: {
|
|
293
|
-
type: 'number',
|
|
294
|
-
'x-jsf-logic-computedAttrs': {
|
|
295
|
-
title: {
|
|
296
|
-
rule: {
|
|
297
|
-
'+': [{ var: 'IdontExist' }, 10],
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
export const schemaWithComputedAttributeThatDoesntExistTitle = {
|
|
306
|
-
properties: {
|
|
307
|
-
field_a: {
|
|
308
|
-
type: 'number',
|
|
309
|
-
'x-jsf-logic-computedAttrs': {
|
|
310
|
-
title: `this doesn't exist {{iDontExist}}`,
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export const schemaWithComputedAttributeThatDoesntExistDescription = {
|
|
317
|
-
properties: {
|
|
318
|
-
// iDontExist: { type: 'number'}, this missing causes test to fail
|
|
319
|
-
field_a: {
|
|
320
|
-
type: 'number',
|
|
321
|
-
'x-jsf-logic-computedAttrs': {
|
|
322
|
-
description: `this doesn't exist {{iDontExist}}`,
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
export const schemaWithComputedAttributesAndErrorMessages = {
|
|
329
|
-
properties: {
|
|
330
|
-
field_a: {
|
|
331
|
-
type: 'number',
|
|
332
|
-
},
|
|
333
|
-
field_b: {
|
|
334
|
-
type: 'number',
|
|
335
|
-
'x-jsf-logic-computedAttrs': {
|
|
336
|
-
minimum: 'a_times_two',
|
|
337
|
-
maximum: 'a_times_four',
|
|
338
|
-
'x-jsf-errorMessage': {
|
|
339
|
-
minimum: 'Must be bigger than {{a_times_two}}',
|
|
340
|
-
maximum: 'Must be smaller than {{a_times_four}}',
|
|
341
|
-
},
|
|
342
|
-
'x-jsf-presentation': {
|
|
343
|
-
statement: {
|
|
344
|
-
description: 'Must be bigger than {{a_times_two}} and smaller than {{a_times_four}}',
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
},
|
|
350
|
-
required: ['field_a', 'field_b'],
|
|
351
|
-
'x-jsf-logic': {
|
|
352
|
-
computedValues: {
|
|
353
|
-
a_times_two: {
|
|
354
|
-
rule: {
|
|
355
|
-
'*': [{ var: 'field_a' }, 2],
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
a_times_four: {
|
|
359
|
-
rule: {
|
|
360
|
-
'*': [{ var: 'field_a' }, 4],
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
export const schemaWithDeepVarThatDoesNotExist = {
|
|
368
|
-
properties: {
|
|
369
|
-
field_a: {
|
|
370
|
-
type: 'number',
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
'x-jsf-logic': {
|
|
374
|
-
validations: {
|
|
375
|
-
dummy_rule: {
|
|
376
|
-
errorMessage: 'Random stuff to illustrate a deeply nested rule.',
|
|
377
|
-
rule: {
|
|
378
|
-
'>': [{ var: 'field_a' }, { '*': [2, { '/': [2, { '*': [1, { var: 'field_b' }] }] }] }],
|
|
379
|
-
},
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
required: [],
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
export const schemaWithDeepVarThatDoesNotExistOnFieldset = {
|
|
387
|
-
properties: {
|
|
388
|
-
field_a: {
|
|
389
|
-
type: 'object',
|
|
390
|
-
properties: {
|
|
391
|
-
child: {
|
|
392
|
-
type: 'number',
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
'x-jsf-logic': {
|
|
396
|
-
validations: {
|
|
397
|
-
dummy_rule: {
|
|
398
|
-
errorMessage: 'Must be greater than 10',
|
|
399
|
-
rule: {
|
|
400
|
-
'>': [{ var: 'child' }, { '*': [2, { '/': [2, { '*': [1, { var: 'field_a' }] }] }] }],
|
|
401
|
-
},
|
|
402
|
-
},
|
|
403
|
-
},
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
required: [],
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
export const schemaWithValidationThatDoesNotExistOnProperty = {
|
|
411
|
-
properties: {
|
|
412
|
-
field_a: {
|
|
413
|
-
type: 'number',
|
|
414
|
-
'x-jsf-logic-validations': ['iDontExist'],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
export const schemaWithPropertyThatDoesNotExistInThatLevelButDoesInFieldset = {
|
|
420
|
-
properties: {
|
|
421
|
-
field_a: {
|
|
422
|
-
type: 'object',
|
|
423
|
-
'x-jsf-presentation': {
|
|
424
|
-
inputType: 'fieldset',
|
|
425
|
-
},
|
|
426
|
-
properties: {
|
|
427
|
-
child: {
|
|
428
|
-
type: 'number',
|
|
429
|
-
'x-jsf-logic-validations': ['child_greater_than_10'],
|
|
430
|
-
},
|
|
431
|
-
other_child: {
|
|
432
|
-
type: 'number',
|
|
433
|
-
'x-jsf-logic-validations': ['greater_than_child'],
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
required: ['child', 'other_child'],
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
// the issue here is that this should be nested inside `field_a` in order to not fail.
|
|
440
|
-
'x-jsf-logic': {
|
|
441
|
-
validations: {
|
|
442
|
-
validation_parent: {
|
|
443
|
-
errorMessage: 'Must be greater than 10!',
|
|
444
|
-
rule: {
|
|
445
|
-
'>': [{ var: 'child' }, 10],
|
|
446
|
-
},
|
|
447
|
-
},
|
|
448
|
-
greater_than_child: {
|
|
449
|
-
errorMessage: 'Must be greater than child',
|
|
450
|
-
rule: {
|
|
451
|
-
'>': [{ var: 'other_child' }, { var: 'child' }],
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
required: ['field_a'],
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
export const schemaWithBadOperation = {
|
|
460
|
-
properties: {},
|
|
461
|
-
'x-jsf-logic': {
|
|
462
|
-
validations: {
|
|
463
|
-
badOperator: {
|
|
464
|
-
rule: {
|
|
465
|
-
'++': [10, 2],
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
},
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
export const schemaWithInlineRuleForComputedAttributeWithCopy = {
|
|
473
|
-
properties: {
|
|
474
|
-
field_a: {
|
|
475
|
-
type: 'number',
|
|
476
|
-
},
|
|
477
|
-
field_b: {
|
|
478
|
-
type: 'number',
|
|
479
|
-
'x-jsf-logic-computedAttrs': {
|
|
480
|
-
title: {
|
|
481
|
-
value: 'I need this to work using the {{rule}}.',
|
|
482
|
-
rule: {
|
|
483
|
-
'+': [{ var: 'field_a' }, 10],
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
},
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
export const schemaWithInlineMultipleRulesForComputedAttributes = {
|
|
492
|
-
properties: {
|
|
493
|
-
field_a: {
|
|
494
|
-
type: 'number',
|
|
495
|
-
},
|
|
496
|
-
field_b: {
|
|
497
|
-
type: 'number',
|
|
498
|
-
'x-jsf-logic-computedAttrs': {
|
|
499
|
-
description: {
|
|
500
|
-
value: 'Must be between {{half_a}} and {{double_a}}.',
|
|
501
|
-
half_a: {
|
|
502
|
-
'/': [{ var: 'field_a' }, 2],
|
|
503
|
-
},
|
|
504
|
-
double_a: {
|
|
505
|
-
'*': [{ var: 'field_a' }, 2],
|
|
506
|
-
},
|
|
507
|
-
},
|
|
508
|
-
},
|
|
509
|
-
},
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
export const schemaInlineComputedAttrForTitle = {
|
|
514
|
-
properties: {
|
|
515
|
-
field_a: {
|
|
516
|
-
type: 'number',
|
|
517
|
-
},
|
|
518
|
-
field_b: {
|
|
519
|
-
type: 'number',
|
|
520
|
-
'x-jsf-logic-computedAttrs': {
|
|
521
|
-
title: {
|
|
522
|
-
value: '{{rule}}',
|
|
523
|
-
rule: {
|
|
524
|
-
'+': [{ var: 'field_a' }, 10],
|
|
525
|
-
},
|
|
526
|
-
},
|
|
527
|
-
},
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
export const schemaInlineComputedAttrForMaximumMinimumValues = {
|
|
533
|
-
properties: {
|
|
534
|
-
field_a: {
|
|
535
|
-
type: 'number',
|
|
536
|
-
},
|
|
537
|
-
field_b: {
|
|
538
|
-
type: 'number',
|
|
539
|
-
'x-jsf-logic-computedAttrs': {
|
|
540
|
-
maximum: {
|
|
541
|
-
rule: {
|
|
542
|
-
'+': [{ var: 'field_a' }, 10],
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
minimum: {
|
|
546
|
-
rule: {
|
|
547
|
-
'-': [{ var: 'field_a' }, 10],
|
|
548
|
-
},
|
|
549
|
-
},
|
|
550
|
-
},
|
|
551
|
-
},
|
|
552
|
-
},
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
export const schemaWithJSFLogicAndInlineRule = {
|
|
556
|
-
properties: {
|
|
557
|
-
field_a: {
|
|
558
|
-
type: 'number',
|
|
559
|
-
},
|
|
560
|
-
field_b: {
|
|
561
|
-
type: 'number',
|
|
562
|
-
'x-jsf-logic-computedAttrs': {
|
|
563
|
-
title: {
|
|
564
|
-
value: 'Going to use {{rule}} and {{not_inline}}',
|
|
565
|
-
rule: {
|
|
566
|
-
'+': [{ var: 'field_a' }, 10],
|
|
567
|
-
},
|
|
568
|
-
},
|
|
569
|
-
},
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
'x-jsf-logic': {
|
|
573
|
-
computedValues: {
|
|
574
|
-
not_inline: {
|
|
575
|
-
rule: {
|
|
576
|
-
'+': [1, 3],
|
|
577
|
-
},
|
|
578
|
-
},
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
export const schemaWithGreaterThanChecksForThreeFields = {
|
|
584
|
-
properties: {
|
|
585
|
-
field_a: {
|
|
586
|
-
type: 'number',
|
|
587
|
-
},
|
|
588
|
-
field_b: {
|
|
589
|
-
type: 'number',
|
|
590
|
-
},
|
|
591
|
-
field_c: {
|
|
592
|
-
type: 'number',
|
|
593
|
-
},
|
|
594
|
-
},
|
|
595
|
-
required: ['field_a', 'field_b'],
|
|
596
|
-
'x-jsf-logic': {
|
|
597
|
-
validations: {
|
|
598
|
-
require_c: {
|
|
599
|
-
rule: {
|
|
600
|
-
and: [{ '>': [{ var: 'field_a' }, { var: 'field_b' }] }],
|
|
601
|
-
},
|
|
602
|
-
},
|
|
603
|
-
},
|
|
604
|
-
allOf: [
|
|
605
|
-
{
|
|
606
|
-
if: {
|
|
607
|
-
validations: {
|
|
608
|
-
require_c: {
|
|
609
|
-
const: true,
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
},
|
|
613
|
-
then: {
|
|
614
|
-
required: ['field_c'],
|
|
615
|
-
},
|
|
616
|
-
else: {
|
|
617
|
-
properties: {
|
|
618
|
-
field_c: false,
|
|
619
|
-
},
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
],
|
|
623
|
-
},
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
export const schemaWithPropertiesCheckAndValidationsInAIf = {
|
|
627
|
-
properties: {
|
|
628
|
-
field_a: {
|
|
629
|
-
type: 'number',
|
|
630
|
-
},
|
|
631
|
-
field_b: {
|
|
632
|
-
type: 'number',
|
|
633
|
-
},
|
|
634
|
-
field_c: {
|
|
635
|
-
type: 'number',
|
|
636
|
-
},
|
|
637
|
-
},
|
|
638
|
-
required: ['field_a', 'field_b'],
|
|
639
|
-
'x-jsf-logic': {
|
|
640
|
-
validations: {
|
|
641
|
-
require_c: {
|
|
642
|
-
rule: {
|
|
643
|
-
and: [{ '>': [{ var: 'field_a' }, { var: 'field_b' }] }],
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
},
|
|
647
|
-
allOf: [
|
|
648
|
-
{
|
|
649
|
-
if: {
|
|
650
|
-
validations: {
|
|
651
|
-
require_c: {
|
|
652
|
-
const: true,
|
|
653
|
-
},
|
|
654
|
-
},
|
|
655
|
-
properties: {
|
|
656
|
-
field_a: {
|
|
657
|
-
const: 10,
|
|
658
|
-
},
|
|
659
|
-
},
|
|
660
|
-
},
|
|
661
|
-
then: {
|
|
662
|
-
required: ['field_c'],
|
|
663
|
-
},
|
|
664
|
-
else: {
|
|
665
|
-
properties: {
|
|
666
|
-
field_c: false,
|
|
667
|
-
},
|
|
668
|
-
},
|
|
669
|
-
},
|
|
670
|
-
],
|
|
671
|
-
},
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
export const schemaWithChecksAndThenValidationsOnThen = {
|
|
675
|
-
properties: {
|
|
676
|
-
field_a: {
|
|
677
|
-
type: 'number',
|
|
678
|
-
},
|
|
679
|
-
field_b: {
|
|
680
|
-
type: 'number',
|
|
681
|
-
},
|
|
682
|
-
field_c: {
|
|
683
|
-
type: 'number',
|
|
684
|
-
},
|
|
685
|
-
},
|
|
686
|
-
required: ['field_a', 'field_b'],
|
|
687
|
-
'x-jsf-logic': {
|
|
688
|
-
validations: {
|
|
689
|
-
c_must_be_large: {
|
|
690
|
-
errorMessage: 'Needs more numbers',
|
|
691
|
-
rule: {
|
|
692
|
-
'>': [{ var: 'field_c' }, 200],
|
|
693
|
-
},
|
|
694
|
-
},
|
|
695
|
-
require_c: {
|
|
696
|
-
rule: {
|
|
697
|
-
and: [{ '>': [{ var: 'field_a' }, { var: 'field_b' }] }],
|
|
698
|
-
},
|
|
699
|
-
},
|
|
700
|
-
},
|
|
701
|
-
allOf: [
|
|
702
|
-
{
|
|
703
|
-
if: {
|
|
704
|
-
validations: {
|
|
705
|
-
require_c: {
|
|
706
|
-
const: true,
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
},
|
|
710
|
-
then: {
|
|
711
|
-
required: ['field_c'],
|
|
712
|
-
properties: {
|
|
713
|
-
field_c: {
|
|
714
|
-
description: 'I am a description!',
|
|
715
|
-
'x-jsf-logic-validations': ['c_must_be_large'],
|
|
716
|
-
},
|
|
717
|
-
},
|
|
718
|
-
},
|
|
719
|
-
else: {
|
|
720
|
-
properties: {
|
|
721
|
-
field_c: false,
|
|
722
|
-
},
|
|
723
|
-
},
|
|
724
|
-
},
|
|
725
|
-
],
|
|
726
|
-
},
|
|
727
|
-
};
|
|
728
|
-
|
|
729
|
-
export const schemaWithComputedValueChecksInIf = {
|
|
730
|
-
properties: {
|
|
731
|
-
field_a: {
|
|
732
|
-
type: 'number',
|
|
733
|
-
},
|
|
734
|
-
field_b: {
|
|
735
|
-
type: 'number',
|
|
736
|
-
},
|
|
737
|
-
field_c: {
|
|
738
|
-
type: 'number',
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
required: ['field_a', 'field_b'],
|
|
742
|
-
'x-jsf-logic': {
|
|
743
|
-
computedValues: {
|
|
744
|
-
require_c: {
|
|
745
|
-
rule: {
|
|
746
|
-
and: [{ '>': [{ var: 'field_a' }, { var: 'field_b' }] }],
|
|
747
|
-
},
|
|
748
|
-
},
|
|
749
|
-
},
|
|
750
|
-
allOf: [
|
|
751
|
-
{
|
|
752
|
-
if: {
|
|
753
|
-
computedValues: {
|
|
754
|
-
require_c: {
|
|
755
|
-
const: true,
|
|
756
|
-
},
|
|
757
|
-
},
|
|
758
|
-
},
|
|
759
|
-
then: {
|
|
760
|
-
required: ['field_c'],
|
|
761
|
-
},
|
|
762
|
-
else: {
|
|
763
|
-
properties: {
|
|
764
|
-
field_c: false,
|
|
765
|
-
},
|
|
766
|
-
},
|
|
767
|
-
},
|
|
768
|
-
],
|
|
769
|
-
},
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
export const schemaWithMultipleComputedValueChecks = {
|
|
773
|
-
properties: {
|
|
774
|
-
field_a: {
|
|
775
|
-
type: 'number',
|
|
776
|
-
},
|
|
777
|
-
field_b: {
|
|
778
|
-
type: 'number',
|
|
779
|
-
},
|
|
780
|
-
field_c: {
|
|
781
|
-
type: 'number',
|
|
782
|
-
},
|
|
783
|
-
},
|
|
784
|
-
required: ['field_a', 'field_b'],
|
|
785
|
-
'x-jsf-logic': {
|
|
786
|
-
validations: {
|
|
787
|
-
double_b: {
|
|
788
|
-
errorMessage: 'Must be two times B',
|
|
789
|
-
rule: {
|
|
790
|
-
'>': [{ var: 'field_c' }, { '*': [{ var: 'field_b' }, 2] }],
|
|
791
|
-
},
|
|
792
|
-
},
|
|
793
|
-
},
|
|
794
|
-
computedValues: {
|
|
795
|
-
a_times_two: {
|
|
796
|
-
rule: {
|
|
797
|
-
'*': [{ var: 'field_a' }, 2],
|
|
798
|
-
},
|
|
799
|
-
},
|
|
800
|
-
mod_by_five: {
|
|
801
|
-
rule: {
|
|
802
|
-
'%': [{ var: 'field_b' }, 5],
|
|
803
|
-
},
|
|
804
|
-
},
|
|
805
|
-
},
|
|
806
|
-
allOf: [
|
|
807
|
-
{
|
|
808
|
-
if: {
|
|
809
|
-
computedValues: {
|
|
810
|
-
a_times_two: {
|
|
811
|
-
const: 20,
|
|
812
|
-
},
|
|
813
|
-
mod_by_five: {
|
|
814
|
-
const: 3,
|
|
815
|
-
},
|
|
816
|
-
},
|
|
817
|
-
},
|
|
818
|
-
then: {
|
|
819
|
-
required: ['field_c'],
|
|
820
|
-
properties: {
|
|
821
|
-
field_c: {
|
|
822
|
-
'x-jsf-logic-validations': ['double_b'],
|
|
823
|
-
title: 'Adding a title.',
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
},
|
|
827
|
-
else: {
|
|
828
|
-
properties: {
|
|
829
|
-
field_c: false,
|
|
830
|
-
},
|
|
831
|
-
},
|
|
832
|
-
},
|
|
833
|
-
],
|
|
834
|
-
},
|
|
835
|
-
};
|
|
836
|
-
|
|
837
|
-
export const schemaWithIfStatementWithComputedValuesAndValidationChecks = {
|
|
838
|
-
properties: {
|
|
839
|
-
field_a: {
|
|
840
|
-
type: 'number',
|
|
841
|
-
},
|
|
842
|
-
field_b: {
|
|
843
|
-
type: 'number',
|
|
844
|
-
},
|
|
845
|
-
field_c: {
|
|
846
|
-
type: 'number',
|
|
847
|
-
},
|
|
848
|
-
},
|
|
849
|
-
required: ['field_a', 'field_b'],
|
|
850
|
-
'x-jsf-logic': {
|
|
851
|
-
validations: {
|
|
852
|
-
greater_than_b: {
|
|
853
|
-
rule: {
|
|
854
|
-
'>': [{ var: 'field_a' }, { var: 'field_b' }],
|
|
855
|
-
},
|
|
856
|
-
},
|
|
857
|
-
},
|
|
858
|
-
computedValues: {
|
|
859
|
-
a_times_two: {
|
|
860
|
-
rule: {
|
|
861
|
-
'*': [{ var: 'field_a' }, 2],
|
|
862
|
-
},
|
|
863
|
-
},
|
|
864
|
-
},
|
|
865
|
-
allOf: [
|
|
866
|
-
{
|
|
867
|
-
if: {
|
|
868
|
-
computedValues: {
|
|
869
|
-
a_times_two: {
|
|
870
|
-
const: 20,
|
|
871
|
-
},
|
|
872
|
-
},
|
|
873
|
-
validations: {
|
|
874
|
-
greater_than_b: {
|
|
875
|
-
const: true,
|
|
876
|
-
},
|
|
877
|
-
},
|
|
878
|
-
},
|
|
879
|
-
then: {
|
|
880
|
-
required: ['field_c'],
|
|
881
|
-
},
|
|
882
|
-
else: {
|
|
883
|
-
properties: {
|
|
884
|
-
field_c: false,
|
|
885
|
-
},
|
|
886
|
-
},
|
|
887
|
-
},
|
|
888
|
-
],
|
|
889
|
-
},
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
export const schemaWhereValidationAndComputedValueIsAppliedOnNormalThenStatement = {
|
|
893
|
-
properties: {
|
|
894
|
-
field_a: {
|
|
895
|
-
type: 'number',
|
|
896
|
-
},
|
|
897
|
-
field_b: {
|
|
898
|
-
type: 'number',
|
|
899
|
-
},
|
|
900
|
-
},
|
|
901
|
-
'x-jsf-logic': {
|
|
902
|
-
computedValues: {
|
|
903
|
-
a_plus_ten: {
|
|
904
|
-
rule: {
|
|
905
|
-
'+': [{ var: 'field_a' }, 10],
|
|
906
|
-
},
|
|
907
|
-
},
|
|
908
|
-
},
|
|
909
|
-
validations: {
|
|
910
|
-
greater_than_a_plus_ten: {
|
|
911
|
-
errorMessage: 'Must be greater than Field A + 10',
|
|
912
|
-
rule: {
|
|
913
|
-
'>': [{ var: 'field_b' }, { '+': [{ var: 'field_a' }, 10] }],
|
|
914
|
-
},
|
|
915
|
-
},
|
|
916
|
-
},
|
|
917
|
-
},
|
|
918
|
-
allOf: [
|
|
919
|
-
{
|
|
920
|
-
if: {
|
|
921
|
-
properties: {
|
|
922
|
-
field_a: {
|
|
923
|
-
const: 20,
|
|
924
|
-
},
|
|
925
|
-
},
|
|
926
|
-
},
|
|
927
|
-
then: {
|
|
928
|
-
properties: {
|
|
929
|
-
field_b: {
|
|
930
|
-
'x-jsf-logic-computedAttrs': {
|
|
931
|
-
title: 'Must be greater than {{a_plus_ten}}.',
|
|
932
|
-
},
|
|
933
|
-
'x-jsf-logic-validations': ['greater_than_a_plus_ten'],
|
|
934
|
-
},
|
|
935
|
-
},
|
|
936
|
-
},
|
|
937
|
-
},
|
|
938
|
-
],
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
export const schemaWithTwoValidationsWhereOneOfThemIsAppliedConditionally = {
|
|
942
|
-
required: ['field_a', 'field_b'],
|
|
943
|
-
properties: {
|
|
944
|
-
field_a: {
|
|
945
|
-
type: 'number',
|
|
946
|
-
},
|
|
947
|
-
field_b: {
|
|
948
|
-
type: 'number',
|
|
949
|
-
'x-jsf-logic-validations': ['greater_than_field_a'],
|
|
950
|
-
},
|
|
951
|
-
},
|
|
952
|
-
'x-jsf-logic': {
|
|
953
|
-
validations: {
|
|
954
|
-
greater_than_field_a: {
|
|
955
|
-
errorMessage: 'Must be greater than A',
|
|
956
|
-
rule: {
|
|
957
|
-
'>': [{ var: 'field_b' }, { var: 'field_a' }],
|
|
958
|
-
},
|
|
959
|
-
},
|
|
960
|
-
greater_than_two_times_a: {
|
|
961
|
-
errorMessage: 'Must be greater than two times A',
|
|
962
|
-
rule: {
|
|
963
|
-
'>': [{ var: 'field_b' }, { '*': [{ var: 'field_a' }, 2] }],
|
|
964
|
-
},
|
|
965
|
-
},
|
|
966
|
-
},
|
|
967
|
-
},
|
|
968
|
-
allOf: [
|
|
969
|
-
{
|
|
970
|
-
if: {
|
|
971
|
-
properties: {
|
|
972
|
-
field_a: {
|
|
973
|
-
const: 20,
|
|
974
|
-
},
|
|
975
|
-
},
|
|
976
|
-
},
|
|
977
|
-
then: {
|
|
978
|
-
properties: {
|
|
979
|
-
field_b: {
|
|
980
|
-
'x-jsf-logic-validations': ['greater_than_two_times_a'],
|
|
981
|
-
},
|
|
982
|
-
},
|
|
983
|
-
},
|
|
984
|
-
},
|
|
985
|
-
],
|
|
986
|
-
};
|