@jsonforms/core 3.0.0-alpha.1 → 3.0.0-alpha.2

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.
Files changed (174) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/globals.html +716 -401
  3. package/docs/index.html +60 -36
  4. package/docs/interfaces/addcellrendereraction.html +3 -3
  5. package/docs/interfaces/addrendereraction.html +3 -3
  6. package/docs/interfaces/adduischemaaction.html +3 -3
  7. package/docs/interfaces/arraycontrolprops.html +21 -21
  8. package/docs/interfaces/arraylayoutprops.html +21 -21
  9. package/docs/interfaces/cellprops.html +14 -14
  10. package/docs/interfaces/combinatorrendererprops.html +13 -13
  11. package/docs/interfaces/controlprops.html +16 -16
  12. package/docs/interfaces/controlstate.html +2 -2
  13. package/docs/interfaces/controlwithdetailprops.html +17 -17
  14. package/docs/interfaces/dispatchcellprops.html +13 -13
  15. package/docs/interfaces/dispatchcellstateprops.html +13 -13
  16. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  17. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  18. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  19. package/docs/interfaces/enumcellprops.html +15 -15
  20. package/docs/interfaces/enumoption.html +2 -2
  21. package/docs/interfaces/initaction.html +6 -6
  22. package/docs/interfaces/initactionoptions.html +3 -3
  23. package/docs/interfaces/jsonformscore.html +7 -7
  24. package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
  25. package/docs/interfaces/jsonformsprops.html +9 -9
  26. package/docs/interfaces/jsonformssubstates.html +11 -1
  27. package/docs/interfaces/layoutprops.html +10 -10
  28. package/docs/interfaces/ownpropsofcell.html +10 -10
  29. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  30. package/docs/interfaces/ownpropsofenum.html +1 -1
  31. package/docs/interfaces/ownpropsofenumcell.html +11 -11
  32. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  33. package/docs/interfaces/ownpropsoflayout.html +9 -9
  34. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  35. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  36. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  37. package/docs/interfaces/removecellrendereraction.html +3 -3
  38. package/docs/interfaces/removerendereraction.html +3 -3
  39. package/docs/interfaces/removeuischemaaction.html +2 -2
  40. package/docs/interfaces/rendererprops.html +9 -9
  41. package/docs/interfaces/setajvaction.html +3 -3
  42. package/docs/interfaces/setconfigaction.html +2 -2
  43. package/docs/interfaces/setlocaleaction.html +3 -3
  44. package/docs/interfaces/setschemaaction.html +2 -2
  45. package/docs/interfaces/{setlocalizedschemasaction.html → settranslatoraction.html} +29 -15
  46. package/docs/interfaces/setuischemaaction.html +2 -2
  47. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  48. package/docs/interfaces/statepropsofarraycontrol.html +17 -17
  49. package/docs/interfaces/statepropsofarraylayout.html +17 -17
  50. package/docs/interfaces/statepropsofcell.html +13 -13
  51. package/docs/interfaces/statepropsofcombinator.html +12 -12
  52. package/docs/interfaces/statepropsofcontrol.html +15 -15
  53. package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
  54. package/docs/interfaces/statepropsofenumcell.html +14 -14
  55. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  56. package/docs/interfaces/statepropsoflayout.html +10 -10
  57. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  58. package/docs/interfaces/statepropsofrenderer.html +9 -9
  59. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  60. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  61. package/docs/interfaces/updateaction.html +3 -3
  62. package/docs/interfaces/updatecoreaction.html +6 -6
  63. package/docs/interfaces/updateerrorsaction.html +2 -2
  64. package/docs/interfaces/{setlocalizeduischemasaction.html → updatei18naction.html} +43 -15
  65. package/docs/interfaces/withclassname.html +1 -1
  66. package/lib/Helpers.js +1 -0
  67. package/lib/Helpers.js.map +1 -1
  68. package/lib/actions/actions.d.ts +29 -25
  69. package/lib/actions/actions.js +52 -28
  70. package/lib/actions/actions.js.map +1 -1
  71. package/lib/configDefault.js +1 -0
  72. package/lib/configDefault.js.map +1 -1
  73. package/lib/generators/Generate.js +1 -0
  74. package/lib/generators/Generate.js.map +1 -1
  75. package/lib/generators/schema.js +3 -1
  76. package/lib/generators/schema.js.map +1 -1
  77. package/lib/generators/uischema.js +5 -2
  78. package/lib/generators/uischema.js.map +1 -1
  79. package/lib/i18n/i18nTypes.d.ts +15 -0
  80. package/lib/i18n/i18nTypes.js +3 -0
  81. package/lib/i18n/i18nTypes.js.map +1 -0
  82. package/lib/i18n/i18nUtil.d.ts +11 -0
  83. package/lib/i18n/i18nUtil.js +58 -0
  84. package/lib/i18n/i18nUtil.js.map +1 -0
  85. package/lib/i18n/index.d.ts +2 -0
  86. package/lib/i18n/index.js +6 -0
  87. package/lib/i18n/index.js.map +1 -0
  88. package/lib/index.d.ts +1 -0
  89. package/lib/index.js +3 -0
  90. package/lib/index.js.map +1 -1
  91. package/lib/jsonforms-core.js +9 -3
  92. package/lib/jsonforms-core.js.map +1 -1
  93. package/lib/models/draft4.js +1 -0
  94. package/lib/models/draft4.js.map +1 -1
  95. package/lib/models/index.js +3 -0
  96. package/lib/models/index.js.map +1 -1
  97. package/lib/models/uischema.js +5 -2
  98. package/lib/models/uischema.js.map +1 -1
  99. package/lib/reducers/cells.js +3 -1
  100. package/lib/reducers/cells.js.map +1 -1
  101. package/lib/reducers/config.js +3 -1
  102. package/lib/reducers/config.js.map +1 -1
  103. package/lib/reducers/core.d.ts +3 -2
  104. package/lib/reducers/core.js +72 -37
  105. package/lib/reducers/core.js.map +1 -1
  106. package/lib/reducers/default-data.js +5 -2
  107. package/lib/reducers/default-data.js.map +1 -1
  108. package/lib/reducers/i18n.d.ts +7 -10
  109. package/lib/reducers/i18n.js +38 -20
  110. package/lib/reducers/i18n.js.map +1 -1
  111. package/lib/reducers/reducers.d.ts +8 -7
  112. package/lib/reducers/reducers.js +25 -17
  113. package/lib/reducers/reducers.js.map +1 -1
  114. package/lib/reducers/renderers.js +3 -1
  115. package/lib/reducers/renderers.js.map +1 -1
  116. package/lib/reducers/selectors.d.ts +1 -1
  117. package/lib/reducers/selectors.js +17 -8
  118. package/lib/reducers/selectors.js.map +1 -1
  119. package/lib/reducers/uischemas.js +5 -2
  120. package/lib/reducers/uischemas.js.map +1 -1
  121. package/lib/store.d.ts +5 -4
  122. package/lib/testers/testers.js +39 -19
  123. package/lib/testers/testers.js.map +1 -1
  124. package/lib/util/array.js +1 -0
  125. package/lib/util/array.js.map +1 -1
  126. package/lib/util/cell.js +25 -9
  127. package/lib/util/cell.js.map +1 -1
  128. package/lib/util/combinators.js +5 -2
  129. package/lib/util/combinators.js.map +1 -1
  130. package/lib/util/ids.js +7 -3
  131. package/lib/util/ids.js.map +1 -1
  132. package/lib/util/index.js +2 -0
  133. package/lib/util/index.js.map +1 -1
  134. package/lib/util/label.js +5 -2
  135. package/lib/util/label.js.map +1 -1
  136. package/lib/util/path.js +9 -4
  137. package/lib/util/path.js.map +1 -1
  138. package/lib/util/renderer.d.ts +13 -4
  139. package/lib/util/renderer.js +120 -39
  140. package/lib/util/renderer.js.map +1 -1
  141. package/lib/util/resolvers.js +7 -3
  142. package/lib/util/resolvers.js.map +1 -1
  143. package/lib/util/runtime.d.ts +4 -5
  144. package/lib/util/runtime.js +15 -7
  145. package/lib/util/runtime.js.map +1 -1
  146. package/lib/util/schema.js +3 -1
  147. package/lib/util/schema.js.map +1 -1
  148. package/lib/util/uischema.js +7 -3
  149. package/lib/util/uischema.js.map +1 -1
  150. package/lib/util/util.d.ts +1 -1
  151. package/lib/util/util.js +9 -4
  152. package/lib/util/util.js.map +1 -1
  153. package/lib/util/validator.d.ts +3 -2
  154. package/lib/util/validator.js +8 -7
  155. package/lib/util/validator.js.map +1 -1
  156. package/package.json +5 -4
  157. package/src/actions/actions.ts +46 -36
  158. package/src/i18n/i18nTypes.ts +17 -0
  159. package/src/i18n/i18nUtil.ts +76 -0
  160. package/src/i18n/index.ts +2 -0
  161. package/src/index.ts +1 -0
  162. package/src/reducers/core.ts +70 -48
  163. package/src/reducers/i18n.ts +41 -35
  164. package/src/reducers/reducers.ts +10 -9
  165. package/src/reducers/selectors.ts +1 -1
  166. package/src/store.ts +4 -4
  167. package/src/util/cell.ts +24 -4
  168. package/src/util/renderer.ts +116 -27
  169. package/src/util/runtime.ts +1 -1
  170. package/src/util/util.ts +1 -1
  171. package/src/util/validator.ts +5 -9
  172. package/test/reducers/core.test.ts +29 -41
  173. package/test/util/cell.test.ts +2 -2
  174. package/test/util/renderer.test.ts +425 -4
@@ -25,7 +25,6 @@
25
25
 
26
26
  import get from 'lodash/get';
27
27
  import { ControlElement, JsonSchema, UISchemaElement } from '../models';
28
- import union from 'lodash/union';
29
28
  import find from 'lodash/find';
30
29
  import {
31
30
  findUISchema,
@@ -34,9 +33,11 @@ import {
34
33
  getConfig,
35
34
  getData,
36
35
  getErrorAt,
36
+ getErrorTranslator,
37
37
  getRenderers,
38
38
  getSchema,
39
39
  getSubErrorsAt,
40
+ getTranslator,
40
41
  getUiSchema,
41
42
  JsonFormsCellRendererRegistryEntry,
42
43
  JsonFormsRendererRegistryEntry,
@@ -48,12 +49,13 @@ import { createLabelDescriptionFrom } from './label';
48
49
  import { CombinatorKeyword, resolveSubSchemas } from './combinators';
49
50
  import { moveDown, moveUp } from './array';
50
51
  import { AnyAction, Dispatch } from './type';
51
- import { formatErrorMessage, Resolve } from './util';
52
+ import { Resolve } from './util';
52
53
  import { composePaths, composeWithUi } from './path';
53
54
  import { isVisible } from './runtime';
54
55
  import { CoreActions, update } from '../actions';
55
56
  import { ErrorObject } from 'ajv';
56
57
  import { JsonFormsState } from '../store';
58
+ import { getCombinedErrorMessage, getI18nKey, i18nJsonSchema, Translator } from '../i18n';
57
59
 
58
60
  export { JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry };
59
61
 
@@ -88,6 +90,7 @@ const isRequired = (
88
90
  *
89
91
  * @param {string} label the label string
90
92
  * @param {boolean} required whether the label belongs to a control which is required
93
+ * @param {boolean} hideRequiredAsterisk applied UI Schema option
91
94
  * @returns {string} the label string
92
95
  */
93
96
  export const computeLabel = (
@@ -98,6 +101,20 @@ export const computeLabel = (
98
101
  return required && !hideRequiredAsterisk ? label + '*' : label;
99
102
  };
100
103
 
104
+ /**
105
+ * Indicates whether to mark a field as required.
106
+ *
107
+ * @param {boolean} required whether the label belongs to a control which is required
108
+ * @param {boolean} hideRequiredAsterisk applied UI Schema option
109
+ * @returns {boolean} should the field be marked as required
110
+ */
111
+ export const showAsRequired = (
112
+ required: boolean,
113
+ hideRequiredAsterisk: boolean
114
+ ): boolean => {
115
+ return required && !hideRequiredAsterisk;
116
+ };
117
+
101
118
  /**
102
119
  * Create a default value based on the given scheam.
103
120
  * @param schema the schema for which to create a default value.
@@ -159,16 +176,45 @@ export interface EnumOption {
159
176
  value: any;
160
177
  }
161
178
 
162
- export const enumToEnumOptionMapper = (e: any): EnumOption => {
163
- const stringifiedEnum = typeof e === 'string' ? e : JSON.stringify(e);
164
- return { label: stringifiedEnum, value: e };
179
+ export const enumToEnumOptionMapper = (
180
+ e: any,
181
+ t?: Translator,
182
+ i18nKey?: string
183
+ ): EnumOption => {
184
+ let label = typeof e === 'string' ? e : JSON.stringify(e);
185
+ if (t) {
186
+ if (i18nKey) {
187
+ label = t(`${i18nKey}.${label}`, label);
188
+ } else {
189
+ label = t(label, label);
190
+ }
191
+ }
192
+ return { label, value: e };
165
193
  };
166
194
 
167
- export const oneOfToEnumOptionMapper = (e: any): EnumOption => ({
168
- value: e.const,
169
- label:
170
- e.title ?? (typeof e.const === 'string' ? e.const : JSON.stringify(e.const))
171
- });
195
+ export const oneOfToEnumOptionMapper = (
196
+ e: any,
197
+ t?: Translator,
198
+ uiSchemaI18nKey?: string
199
+ ): EnumOption => {
200
+ let label =
201
+ e.title ??
202
+ (typeof e.const === 'string' ? e.const : JSON.stringify(e.const));
203
+ if (t) {
204
+ // prefer schema keys as they can be more specialized
205
+ if (e.i18n) {
206
+ label = t(e.i18n, label);
207
+ } else if (uiSchemaI18nKey) {
208
+ label = t(`${uiSchemaI18nKey}.${label}`, label);
209
+ } else {
210
+ label = t(label, label);
211
+ }
212
+ }
213
+ return {
214
+ label,
215
+ value: e.const,
216
+ };
217
+ };
172
218
 
173
219
  export interface OwnPropsOfRenderer {
174
220
  /**
@@ -398,9 +444,8 @@ export const mapStateToControlProps = (
398
444
  controlElement.scope,
399
445
  rootSchema
400
446
  );
401
- const errors = formatErrorMessage(
402
- union(getErrorAt(path, resolvedSchema)(state).map(error => error.message))
403
- );
447
+ const errors = getErrorAt(path, resolvedSchema)(state);
448
+
404
449
  const description =
405
450
  resolvedSchema !== undefined ? resolvedSchema.description : '';
406
451
  const data = Resolve.data(rootData, path);
@@ -415,18 +460,26 @@ export const mapStateToControlProps = (
415
460
  rootData,
416
461
  config
417
462
  );
463
+
464
+ const schema = resolvedSchema ?? rootSchema;
465
+ const t = getTranslator()(state);
466
+ const te = getErrorTranslator()(state);
467
+ const i18nLabel = t(getI18nKey(schema, uischema, 'label') ?? label, label);
468
+ const i18nDescription = t(getI18nKey(schema, uischema, 'description') ?? description, description);
469
+ const i18nErrorMessage = getCombinedErrorMessage(errors, te, t, schema, uischema);
470
+
418
471
  return {
419
472
  data,
420
- description,
421
- errors,
422
- label,
473
+ description: i18nDescription,
474
+ errors: i18nErrorMessage,
475
+ label: i18nLabel,
423
476
  visible,
424
477
  enabled,
425
478
  id,
426
479
  path,
427
480
  required,
428
- uischema: ownProps.uischema,
429
- schema: resolvedSchema || rootSchema,
481
+ uischema,
482
+ schema,
430
483
  config: getConfig(state),
431
484
  cells: ownProps.cells || state.jsonforms.cells,
432
485
  rootSchema
@@ -461,8 +514,20 @@ export const mapStateToEnumControlProps = (
461
514
  const props: StatePropsOfControl = mapStateToControlProps(state, ownProps);
462
515
  const options: EnumOption[] =
463
516
  ownProps.options ||
464
- props.schema.enum?.map(enumToEnumOptionMapper) ||
465
- (props.schema.const && [enumToEnumOptionMapper(props.schema.const)]);
517
+ props.schema.enum?.map(e =>
518
+ enumToEnumOptionMapper(
519
+ e,
520
+ getTranslator()(state),
521
+ props.uischema?.options?.i18n ?? (props.schema as i18nJsonSchema).i18n
522
+ )
523
+ ) ||
524
+ (props.schema.const && [
525
+ enumToEnumOptionMapper(
526
+ props.schema.const,
527
+ getTranslator()(state),
528
+ props.uischema?.options?.i18n ?? (props.schema as i18nJsonSchema).i18n
529
+ )
530
+ ]);
466
531
  return {
467
532
  ...props,
468
533
  options
@@ -482,7 +547,13 @@ export const mapStateToOneOfEnumControlProps = (
482
547
  const props: StatePropsOfControl = mapStateToControlProps(state, ownProps);
483
548
  const options: EnumOption[] =
484
549
  ownProps.options ||
485
- (props.schema.oneOf as JsonSchema[])?.map(oneOfToEnumOptionMapper);
550
+ (props.schema.oneOf as JsonSchema[])?.map(oneOfSubSchema =>
551
+ oneOfToEnumOptionMapper(
552
+ oneOfSubSchema,
553
+ getTranslator()(state),
554
+ props.uischema?.options?.i18n
555
+ )
556
+ );
486
557
  return {
487
558
  ...props,
488
559
  options
@@ -504,8 +575,20 @@ export const mapStateToMultiEnumControlProps = (
504
575
  const options: EnumOption[] =
505
576
  ownProps.options ||
506
577
  (items?.oneOf &&
507
- (items.oneOf as JsonSchema[]).map(oneOfToEnumOptionMapper)) ||
508
- items?.enum?.map(enumToEnumOptionMapper);
578
+ (items.oneOf as JsonSchema[]).map(oneOfSubSchema =>
579
+ oneOfToEnumOptionMapper(
580
+ oneOfSubSchema,
581
+ state.jsonforms.i18n?.translate,
582
+ props.uischema?.options?.i18n
583
+ )
584
+ )) ||
585
+ items?.enum?.map(e =>
586
+ enumToEnumOptionMapper(
587
+ e,
588
+ state.jsonforms.i18n?.translate,
589
+ props.uischema?.options?.i18n ?? (props.schema as i18nJsonSchema).i18n
590
+ )
591
+ );
509
592
  return {
510
593
  ...props,
511
594
  options
@@ -961,9 +1044,17 @@ export const mapStateToArrayLayoutProps = (
961
1044
  } = mapStateToControlWithDetailProps(state, ownProps);
962
1045
 
963
1046
  const resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
964
- const childErrors = formatErrorMessage(
965
- getSubErrorsAt(path, resolvedSchema)(state).map(error => error.message)
1047
+
1048
+ // TODO Does not consider a specialized '.custom' error message overriding all other error messages
1049
+ // TODO Does not consider 'i18n' keys which are specified in the ui schemas of the sub errors
1050
+ const childErrors = getCombinedErrorMessage(
1051
+ getSubErrorsAt(path, resolvedSchema)(state),
1052
+ getErrorTranslator()(state),
1053
+ getTranslator()(state),
1054
+ undefined,
1055
+ undefined
966
1056
  );
1057
+
967
1058
  const allErrors =
968
1059
  errors +
969
1060
  (errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
@@ -979,8 +1070,6 @@ export const mapStateToArrayLayoutProps = (
979
1070
  };
980
1071
  };
981
1072
 
982
- export type CombinatorProps = StatePropsOfCombinator & DispatchPropsOfControl;
983
-
984
1073
  /**
985
1074
  * Props of an array control.
986
1075
  */
@@ -36,7 +36,7 @@ import {
36
36
  } from '../models';
37
37
  import { resolveData } from './resolvers';
38
38
  import { composeWithUi } from './path';
39
- import { Ajv } from 'ajv';
39
+ import Ajv from 'ajv';
40
40
  import { getAjv } from '../reducers';
41
41
  import { JsonFormsState } from '../store';
42
42
  import { JsonSchema } from '../models/jsonSchema';
package/src/util/util.ts CHANGED
@@ -31,7 +31,7 @@ import { JsonSchema, Scopable, UISchemaElement } from '..';
31
31
  import { resolveData, resolveSchema } from './resolvers';
32
32
  import { composePaths, toDataPathSegments } from './path';
33
33
  import { isEnabled, isVisible } from './runtime';
34
- import { Ajv } from 'ajv';
34
+ import Ajv from 'ajv';
35
35
 
36
36
  /**
37
37
  * Escape the given string such that it can be used as a class name,
@@ -22,21 +22,17 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
-
26
- import AJV from 'ajv';
25
+ import Ajv from 'ajv';
26
+ import addFormats from 'ajv-formats';
27
27
  import { Options } from 'ajv';
28
- import { Draft4 } from '../models';
29
28
 
30
29
  export const createAjv = (options?: Options) => {
31
- const ajv = new AJV({
32
- schemaId: 'auto',
30
+ const ajv = new Ajv({
33
31
  allErrors: true,
34
- jsonPointers: true,
35
- errorDataPath: 'property',
36
32
  verbose: true,
33
+ strict: false,
37
34
  ...options
38
35
  });
39
- ajv.addFormat('time', '^([0-1][0-9]|2[0-3]):[0-5][0-9]$');
40
- ajv.addMetaSchema(Draft4);
36
+ addFormats(ajv);
41
37
  return ajv;
42
38
  };
@@ -23,14 +23,14 @@
23
23
  THE SOFTWARE.
24
24
  */
25
25
  import test from 'ava';
26
- import AJV from 'ajv';
26
+ import Ajv from 'ajv';
27
27
  import { coreReducer } from '../../src/reducers';
28
28
  import { init, update, updateErrors } from '../../src/actions';
29
29
  import { JsonSchema } from '../../src/models/jsonSchema';
30
30
  import {
31
31
  errorAt,
32
32
  JsonFormsCore,
33
- sanitizeErrors,
33
+ validate,
34
34
  subErrorsAt
35
35
  } from '../../src/reducers/core';
36
36
 
@@ -84,9 +84,7 @@ test('core reducer - no previous state - init with ajv as options object should
84
84
  }
85
85
  }
86
86
  };
87
- const myAjv = new AJV({
88
- errorDataPath: 'mypath'
89
- });
87
+ const myAjv = new Ajv();
90
88
  const after = coreReducer(undefined, init({}, schema, undefined, myAjv));
91
89
  t.deepEqual(after.ajv, myAjv);
92
90
  });
@@ -115,9 +113,7 @@ test('core reducer - no previous state - init with options object with ajv', t =
115
113
  }
116
114
  }
117
115
  };
118
- const myAjv = new AJV({
119
- errorDataPath: 'mypath'
120
- });
116
+ const myAjv = new Ajv();
121
117
  const after = coreReducer(
122
118
  undefined,
123
119
  init({}, schema, undefined, {
@@ -137,9 +133,7 @@ test('core reducer - previous state - init without options should keep previous
137
133
  }
138
134
  }
139
135
  };
140
- const myAjv = new AJV({
141
- errorDataPath: 'mypath'
142
- });
136
+ const myAjv = new Ajv();
143
137
  const after = coreReducer(
144
138
  {
145
139
  data: {},
@@ -164,12 +158,8 @@ test('core reducer - previous state - init with ajv options object should overwr
164
158
  }
165
159
  }
166
160
  };
167
- const previousAjv = new AJV({
168
- errorDataPath: 'mypath'
169
- });
170
- const newAjv = new AJV({
171
- errorDataPath: 'newajv'
172
- });
161
+ const previousAjv = new Ajv();
162
+ const newAjv = new Ajv();
173
163
  const after = coreReducer(
174
164
  {
175
165
  data: {},
@@ -194,9 +184,7 @@ test('core reducer - previous state - init with empty options should not overwri
194
184
  }
195
185
  }
196
186
  };
197
- const myAjv = new AJV({
198
- errorDataPath: 'mypath'
199
- });
187
+ const myAjv = new Ajv();
200
188
  const after = coreReducer(
201
189
  {
202
190
  data: {},
@@ -279,7 +267,7 @@ test('core reducer - update - undefined data should update for given path', t =>
279
267
  type: 'Label'
280
268
  },
281
269
  errors: [],
282
- validator: new AJV().compile(schema)
270
+ validator: new Ajv().compile(schema)
283
271
  };
284
272
 
285
273
  const after = coreReducer(
@@ -386,7 +374,7 @@ test('core reducer - update - empty path should update root state', t => {
386
374
  uischema: {
387
375
  type: 'Label'
388
376
  },
389
- validator: new AJV().compile(schema)
377
+ validator: new Ajv().compile(schema)
390
378
  };
391
379
 
392
380
  const after = coreReducer(
@@ -427,7 +415,7 @@ test('core reducer - update - providing a path should update data only belonging
427
415
  uischema: {
428
416
  type: 'Label'
429
417
  },
430
- validator: new AJV().compile(schema)
418
+ validator: new Ajv().compile(schema)
431
419
  };
432
420
 
433
421
  const after = coreReducer(
@@ -467,7 +455,7 @@ test('core reducer - update - should update errors', t => {
467
455
  uischema: {
468
456
  type: 'Label'
469
457
  },
470
- validator: new AJV().compile(schema)
458
+ validator: new Ajv().compile(schema)
471
459
  };
472
460
 
473
461
  const after = coreReducer(
@@ -482,9 +470,9 @@ test('core reducer - update - should update errors', t => {
482
470
  data: { ...before.data, color: 'Yellow' },
483
471
  errors: [
484
472
  {
485
- dataPath: 'color',
473
+ instancePath: '/color',
486
474
  keyword: 'enum',
487
- message: 'should be equal to one of the allowed values',
475
+ message: 'must be equal to one of the allowed values',
488
476
  params: {
489
477
  allowedValues: ['Blue', 'Green']
490
478
  },
@@ -514,7 +502,7 @@ test('core reducer - updateErrors - should update errors with error', t => {
514
502
  };
515
503
 
516
504
  const error = {
517
- dataPath: 'color',
505
+ instancePath: '/color',
518
506
  keyword: 'enum',
519
507
  message: 'should be equal to one of the allowed values',
520
508
  params: {
@@ -556,7 +544,7 @@ test('errorAt filters enum', t => {
556
544
  };
557
545
  const data = { foo: '', bar: '' };
558
546
  const v = ajv.compile(schema);
559
- const errors = sanitizeErrors(v, data);
547
+ const errors = validate(v, data);
560
548
 
561
549
  const state: JsonFormsCore = {
562
550
  data,
@@ -587,7 +575,7 @@ test('errorAt filters required', t => {
587
575
  };
588
576
  const data = {};
589
577
  const v = ajv.compile(schema);
590
- const errors = sanitizeErrors(v, data);
578
+ const errors = validate(v, data);
591
579
 
592
580
  const state: JsonFormsCore = {
593
581
  data,
@@ -636,7 +624,7 @@ test('errorAt filters required in oneOf object', t => {
636
624
  };
637
625
  const data = { fooOrBar: { } };
638
626
  const v = ajv.compile(schema);
639
- const errors = sanitizeErrors(v, data);
627
+ const errors = validate(v, data);
640
628
 
641
629
  const state: JsonFormsCore = {
642
630
  data,
@@ -688,7 +676,7 @@ test('errorAt filters required in anyOf object', t => {
688
676
  };
689
677
  const data = { fooOrBar: { } };
690
678
  const v = ajv.compile(schema);
691
- const errors = sanitizeErrors(v, data);
679
+ const errors = validate(v, data);
692
680
 
693
681
  const state: JsonFormsCore = {
694
682
  data,
@@ -736,7 +724,7 @@ test('errorAt filters array minItems', t => {
736
724
  numbers: []
737
725
  };
738
726
  const v = ajv.compile(schema);
739
- const errors = sanitizeErrors(v, data);
727
+ const errors = validate(v, data);
740
728
 
741
729
  const state: JsonFormsCore = {
742
730
  data,
@@ -781,7 +769,7 @@ test('errorAt filters array inner value', t => {
781
769
  numbers: ['Bar']
782
770
  };
783
771
  const v = ajv.compile(schema);
784
- const errors = sanitizeErrors(v, data);
772
+ const errors = validate(v, data);
785
773
 
786
774
  const state: JsonFormsCore = {
787
775
  data,
@@ -817,7 +805,7 @@ test('errorAt filters oneOf simple', t => {
817
805
  };
818
806
  const data: { coloursOrNumbers: string } = { coloursOrNumbers: 'Foo' };
819
807
  const v = ajv.compile(schema);
820
- const errors = sanitizeErrors(v, data);
808
+ const errors = validate(v, data);
821
809
 
822
810
  const state: JsonFormsCore = {
823
811
  data,
@@ -856,7 +844,7 @@ test('errorAt filters anyOf simple', t => {
856
844
  };
857
845
  const data: { coloursOrNumbers: string } = { coloursOrNumbers: 'Foo' };
858
846
  const v = ajv.compile(schema);
859
- const errors = sanitizeErrors(v, data);
847
+ const errors = validate(v, data);
860
848
 
861
849
  const state: JsonFormsCore = {
862
850
  data,
@@ -910,7 +898,7 @@ test('errorAt filters oneOf objects', t => {
910
898
  };
911
899
  const data = { coloursOrNumbers: { colour: 'Foo' } };
912
900
  const v = ajv.compile(schema);
913
- const errors = sanitizeErrors(v, data);
901
+ const errors = validate(v, data);
914
902
 
915
903
  const state: JsonFormsCore = {
916
904
  data,
@@ -962,7 +950,7 @@ test('errorAt filters oneOf objects same properties', t => {
962
950
  };
963
951
  const data = { coloursOrNumbers: { colourOrNumber: 'Foo' } };
964
952
  const v = ajv.compile(schema);
965
- const errors = sanitizeErrors(v, data);
953
+ const errors = validate(v, data);
966
954
 
967
955
  const state: JsonFormsCore = {
968
956
  data,
@@ -1011,7 +999,7 @@ test('errorAt filters oneOf array', t => {
1011
999
  };
1012
1000
  const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: [] };
1013
1001
  const v = ajv.compile(schema);
1014
- const errors = sanitizeErrors(v, data);
1002
+ const errors = validate(v, data);
1015
1003
 
1016
1004
  const state: JsonFormsCore = {
1017
1005
  data,
@@ -1060,7 +1048,7 @@ test('errorAt filters oneOf array inner', t => {
1060
1048
  };
1061
1049
  const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: ['Foo'] };
1062
1050
  const v = ajv.compile(schema);
1063
- const errors = sanitizeErrors(v, data);
1051
+ const errors = validate(v, data);
1064
1052
 
1065
1053
  const state: JsonFormsCore = {
1066
1054
  data,
@@ -1107,7 +1095,7 @@ test('subErrorsAt filters array inner', t => {
1107
1095
  numbers: ['Bar']
1108
1096
  };
1109
1097
  const v = ajv.compile(schema);
1110
- const errors = sanitizeErrors(v, data);
1098
+ const errors = validate(v, data);
1111
1099
 
1112
1100
  const state: JsonFormsCore = {
1113
1101
  data,
@@ -1156,7 +1144,7 @@ test('subErrorsAt filters oneOf array inner', t => {
1156
1144
  };
1157
1145
  const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: ['Foo'] };
1158
1146
  const v = ajv.compile(schema);
1159
- const errors = sanitizeErrors(v, data);
1147
+ const errors = validate(v, data);
1160
1148
 
1161
1149
  const state: JsonFormsCore = {
1162
1150
  data,
@@ -286,7 +286,7 @@ test('mapStateToEnumCellProps - set default options for dropdown list', t => {
286
286
  const props = defaultMapStateToEnumCellProps(createState(uischema), ownProps);
287
287
  t.deepEqual(
288
288
  props.options,
289
- ['DE', 'IT', 'JP', 'US', 'RU', 'Other'].map(enumToEnumOptionMapper)
289
+ ['DE', 'IT', 'JP', 'US', 'RU', 'Other'].map(e => enumToEnumOptionMapper(e))
290
290
  );
291
291
  t.is(props.data, undefined);
292
292
  });
@@ -315,7 +315,7 @@ test('mapStateToOneOfEnumCellProps - set one of options for dropdown list', t =>
315
315
  };
316
316
 
317
317
  const props = mapStateToOneOfEnumCellProps(createState(uischema), ownProps);
318
- t.deepEqual(props.options, [{title: 'Australia' , const: 'AU', }, { title: 'New Zealand', const: 'NZ' }].map(oneOfToEnumOptionMapper));
318
+ t.deepEqual(props.options, [{title: 'Australia' , const: 'AU', }, { title: 'New Zealand', const: 'NZ' }].map(schema => oneOfToEnumOptionMapper(schema)));
319
319
  t.is(props.data, undefined);
320
320
  });
321
321