ejv 2.0.5 → 2.1.1

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 (49) hide show
  1. package/.mocharc.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/README-KR.md +166 -165
  4. package/README.md +182 -178
  5. package/build/cjs/constants.js +112 -107
  6. package/build/cjs/constants.js.map +1 -1
  7. package/build/cjs/ejv.js +245 -177
  8. package/build/cjs/ejv.js.map +1 -1
  9. package/build/cjs/index.js +6 -6
  10. package/build/cjs/index.js.map +1 -1
  11. package/build/cjs/interfaces.js.map +1 -1
  12. package/build/cjs/tester.js +12 -8
  13. package/build/cjs/tester.js.map +1 -1
  14. package/build/cjs/util.js.map +1 -1
  15. package/build/constants.d.ts +10 -5
  16. package/build/esm/constants.js +111 -106
  17. package/build/esm/constants.js.map +1 -1
  18. package/build/esm/ejv.js +247 -179
  19. package/build/esm/ejv.js.map +1 -1
  20. package/build/esm/index.js +1 -1
  21. package/build/esm/index.js.map +1 -1
  22. package/build/esm/interfaces.js.map +1 -1
  23. package/build/esm/tester.js +11 -8
  24. package/build/esm/tester.js.map +1 -1
  25. package/build/esm/util.js.map +1 -1
  26. package/build/index.d.ts +1 -1
  27. package/build/interfaces.d.ts +10 -9
  28. package/build/tester.d.ts +4 -3
  29. package/build/util.d.ts +2 -2
  30. package/eslint.config.mjs +59 -0
  31. package/package.json +17 -13
  32. package/spec/ArrayScheme.ts +46 -46
  33. package/spec/CommonScheme.ts +15 -15
  34. package/spec/DateScheme.ts +22 -22
  35. package/spec/NumberScheme.ts +229 -121
  36. package/spec/ObjectScheme.ts +22 -22
  37. package/spec/RegExpScheme.ts +5 -5
  38. package/spec/StringScheme.ts +223 -126
  39. package/spec/common-test-util.ts +2 -2
  40. package/spec/ejv.spec.ts +20 -20
  41. package/spec/testers.spec.ts +5 -5
  42. package/src/constants.ts +12 -5
  43. package/src/ejv.ts +291 -202
  44. package/src/index.ts +1 -1
  45. package/src/interfaces.ts +11 -12
  46. package/src/tester.ts +14 -10
  47. package/src/util.ts +2 -2
  48. package/tsconfig.json +2 -1
  49. package/.eslintrc.json +0 -88
@@ -4,7 +4,7 @@ import { expect } from 'chai';
4
4
  import { ejv } from '../src/ejv';
5
5
 
6
6
  import { EjvError, Scheme } from '../src/interfaces';
7
- import { ErrorMsg, ErrorType } from '../src/constants';
7
+ import { ERROR_MESSAGE, ERROR_TYPE } from '../src/constants';
8
8
  import { createErrorMsg } from '../src/util';
9
9
  import { checkSchemeError, TypeTester, typeTesterArr } from './common-test-util';
10
10
 
@@ -31,8 +31,8 @@ describe('ArrayScheme', () => {
31
31
  throw new Error('spec failed');
32
32
  }
33
33
 
34
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
35
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
34
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
35
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
36
36
  placeholders: ['array']
37
37
  }));
38
38
  expect(error.path).to.be.eql('a');
@@ -60,8 +60,8 @@ describe('ArrayScheme', () => {
60
60
  throw new Error('spec failed');
61
61
  }
62
62
 
63
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH_ONE_OF);
64
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH_ONE_OF, {
63
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH_ONE_OF);
64
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH_ONE_OF, {
65
65
  placeholders: [JSON.stringify(typeArr)]
66
66
  }));
67
67
  expect(error.path).to.be.eql('a');
@@ -126,8 +126,8 @@ describe('ArrayScheme', () => {
126
126
  throw new Error('spec failed');
127
127
  }
128
128
 
129
- expect(error.type).to.be.eql(ErrorType.ITEMS_TYPE);
130
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ITEMS_TYPE, {
129
+ expect(error.type).to.be.eql(ERROR_TYPE.ITEMS_TYPE);
130
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ITEMS_TYPE, {
131
131
  placeholders: ['string']
132
132
  }));
133
133
  expect(error.path).to.be.eql('a/1');
@@ -166,8 +166,8 @@ describe('ArrayScheme', () => {
166
166
  throw new Error('spec failed');
167
167
  }
168
168
 
169
- expect(error.type).to.be.eql(ErrorType.ITEMS_TYPE);
170
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ITEMS_TYPE, {
169
+ expect(error.type).to.be.eql(ERROR_TYPE.ITEMS_TYPE);
170
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ITEMS_TYPE, {
171
171
  placeholders: ['string']
172
172
  }));
173
173
  expect(error.path).to.be.eql('a/1');
@@ -214,7 +214,7 @@ describe('ArrayScheme', () => {
214
214
  minLength: null as unknown as number
215
215
  },
216
216
 
217
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
217
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
218
218
  });
219
219
  });
220
220
 
@@ -227,7 +227,7 @@ describe('ArrayScheme', () => {
227
227
  minLength: 1.5
228
228
  },
229
229
 
230
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
230
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
231
231
  });
232
232
  });
233
233
 
@@ -240,7 +240,7 @@ describe('ArrayScheme', () => {
240
240
  minLength: '1' as unknown as number
241
241
  },
242
242
 
243
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
243
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
244
244
  });
245
245
  });
246
246
  });
@@ -263,8 +263,8 @@ describe('ArrayScheme', () => {
263
263
  throw new Error('spec failed');
264
264
  }
265
265
 
266
- expect(error.type).to.be.eql(ErrorType.MIN_LENGTH);
267
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.MIN_LENGTH, {
266
+ expect(error.type).to.be.eql(ERROR_TYPE.MIN_LENGTH);
267
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.MIN_LENGTH, {
268
268
  placeholders: [4]
269
269
  }));
270
270
  expect(error.path).to.be.eql('a');
@@ -314,7 +314,7 @@ describe('ArrayScheme', () => {
314
314
  maxLength: null as unknown as number
315
315
  },
316
316
 
317
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
317
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
318
318
  });
319
319
  });
320
320
 
@@ -327,7 +327,7 @@ describe('ArrayScheme', () => {
327
327
  maxLength: 1.5
328
328
  },
329
329
 
330
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
330
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
331
331
  });
332
332
  });
333
333
 
@@ -340,7 +340,7 @@ describe('ArrayScheme', () => {
340
340
  maxLength: '1' as unknown as number
341
341
  },
342
342
 
343
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
343
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
344
344
  });
345
345
  });
346
346
  });
@@ -363,8 +363,8 @@ describe('ArrayScheme', () => {
363
363
  throw new Error('spec failed');
364
364
  }
365
365
 
366
- expect(error.type).to.be.eql(ErrorType.MAX_LENGTH);
367
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.MAX_LENGTH, {
366
+ expect(error.type).to.be.eql(ERROR_TYPE.MAX_LENGTH);
367
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.MAX_LENGTH, {
368
368
  placeholders: [2]
369
369
  }));
370
370
  expect(error.path).to.be.eql('a');
@@ -414,7 +414,7 @@ describe('ArrayScheme', () => {
414
414
  unique: null as unknown as boolean
415
415
  },
416
416
 
417
- message: createErrorMsg(ErrorMsg.UNIQUE_SHOULD_BE_BOOLEAN)
417
+ message: createErrorMsg(ERROR_MESSAGE.UNIQUE_SHOULD_BE_BOOLEAN)
418
418
  });
419
419
  });
420
420
 
@@ -427,7 +427,7 @@ describe('ArrayScheme', () => {
427
427
  unique: 'hello' as unknown as boolean
428
428
  },
429
429
 
430
- message: createErrorMsg(ErrorMsg.UNIQUE_SHOULD_BE_BOOLEAN)
430
+ message: createErrorMsg(ERROR_MESSAGE.UNIQUE_SHOULD_BE_BOOLEAN)
431
431
  });
432
432
  });
433
433
  });
@@ -504,8 +504,8 @@ describe('ArrayScheme', () => {
504
504
  throw new Error('spec failed');
505
505
  }
506
506
 
507
- expect(error.type).to.be.eql(ErrorType.UNIQUE_ITEMS);
508
- expect(error.message).to.be.eql(ErrorMsg.UNIQUE_ITEMS);
507
+ expect(error.type).to.be.eql(ERROR_TYPE.UNIQUE_ITEMS);
508
+ expect(error.message).to.be.eql(ERROR_MESSAGE.UNIQUE_ITEMS);
509
509
  expect(error.path).to.be.eql('b');
510
510
  expect(error.data).to.be.deep.equal(numberTestObj);
511
511
  expect(error.errorData).to.be.ordered.members(numberValue);
@@ -531,8 +531,8 @@ describe('ArrayScheme', () => {
531
531
  throw new Error('spec failed');
532
532
  }
533
533
 
534
- expect(stringsError.type).to.be.eql(ErrorType.UNIQUE_ITEMS);
535
- expect(stringsError.message).to.be.eql(ErrorMsg.UNIQUE_ITEMS);
534
+ expect(stringsError.type).to.be.eql(ERROR_TYPE.UNIQUE_ITEMS);
535
+ expect(stringsError.message).to.be.eql(ERROR_MESSAGE.UNIQUE_ITEMS);
536
536
  expect(stringsError.path).to.be.eql('a');
537
537
  expect(stringsError.data).to.be.deep.equal(stringTestObj);
538
538
  expect(stringsError.errorData).to.be.ordered.members(stringValue);
@@ -562,7 +562,7 @@ describe('ArrayScheme', () => {
562
562
  items: null as unknown as string[]
563
563
  },
564
564
 
565
- message: createErrorMsg(ErrorMsg.INVALID_ITEMS_SCHEME, {
565
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_ITEMS_SCHEME, {
566
566
  placeholders: ['null']
567
567
  })
568
568
  });
@@ -584,7 +584,7 @@ describe('ArrayScheme', () => {
584
584
  items: invalidDataType
585
585
  },
586
586
 
587
- message: createErrorMsg(ErrorMsg.SCHEMES_HAS_INVALID_TYPE, {
587
+ message: createErrorMsg(ERROR_MESSAGE.SCHEMES_HAS_INVALID_TYPE, {
588
588
  placeholders: [invalidDataType]
589
589
  })
590
590
  });
@@ -609,8 +609,8 @@ describe('ArrayScheme', () => {
609
609
  throw new Error('spec failed');
610
610
  }
611
611
 
612
- expect(error.type).to.be.eql(ErrorType.ITEMS_TYPE);
613
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ITEMS_TYPE, {
612
+ expect(error.type).to.be.eql(ERROR_TYPE.ITEMS_TYPE);
613
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ITEMS_TYPE, {
614
614
  placeholders: ['string']
615
615
  }));
616
616
  expect(error.path).to.be.eql('a/0');
@@ -657,7 +657,7 @@ describe('ArrayScheme', () => {
657
657
  items: ['number', invalidDataType]
658
658
  },
659
659
 
660
- message: createErrorMsg(ErrorMsg.SCHEMES_HAS_INVALID_TYPE, {
660
+ message: createErrorMsg(ERROR_MESSAGE.SCHEMES_HAS_INVALID_TYPE, {
661
661
  placeholders: [invalidDataType]
662
662
  })
663
663
  });
@@ -685,8 +685,8 @@ describe('ArrayScheme', () => {
685
685
  throw new Error('spec failed');
686
686
  }
687
687
 
688
- expect(error.type).to.be.eql(ErrorType.ITEMS_TYPE);
689
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ITEMS_TYPE, {
688
+ expect(error.type).to.be.eql(ERROR_TYPE.ITEMS_TYPE);
689
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ITEMS_TYPE, {
690
690
  placeholders: [JSON.stringify(enumArr)]
691
691
  }));
692
692
  expect(error.path).to.be.eql('a/0');
@@ -731,7 +731,7 @@ describe('ArrayScheme', () => {
731
731
  } as unknown as Scheme
732
732
  },
733
733
 
734
- message: createErrorMsg(ErrorMsg.SCHEMES_HAS_INVALID_TYPE, {
734
+ message: createErrorMsg(ERROR_MESSAGE.SCHEMES_HAS_INVALID_TYPE, {
735
735
  placeholders: [invalidDataType]
736
736
  })
737
737
  });
@@ -761,8 +761,8 @@ describe('ArrayScheme', () => {
761
761
  throw new Error('spec failed');
762
762
  }
763
763
 
764
- expect(error.type).to.be.eql(ErrorType.BIGGER_THAN_OR_EQUAL);
765
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.BIGGER_THAN_OR_EQUAL, {
764
+ expect(error.type).to.be.eql(ERROR_TYPE.BIGGER_THAN_OR_EQUAL);
765
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN_OR_EQUAL, {
766
766
  placeholders: [2]
767
767
  }));
768
768
  expect(error.path).to.be.eql('a/0');
@@ -810,8 +810,8 @@ describe('ArrayScheme', () => {
810
810
  throw new Error('spec failed');
811
811
  }
812
812
 
813
- expect(error.type).to.be.eql(ErrorType.BIGGER_THAN_OR_EQUAL);
814
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.BIGGER_THAN_OR_EQUAL, {
813
+ expect(error.type).to.be.eql(ERROR_TYPE.BIGGER_THAN_OR_EQUAL);
814
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN_OR_EQUAL, {
815
815
  placeholders: [4]
816
816
  }));
817
817
  expect(error.path).to.be.eql('a/0/number');
@@ -849,8 +849,8 @@ describe('ArrayScheme', () => {
849
849
  throw new Error('spec failed');
850
850
  }
851
851
 
852
- expect(error.type).to.be.eql(ErrorType.BIGGER_THAN_OR_EQUAL);
853
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.BIGGER_THAN_OR_EQUAL, {
852
+ expect(error.type).to.be.eql(ERROR_TYPE.BIGGER_THAN_OR_EQUAL);
853
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN_OR_EQUAL, {
854
854
  placeholders: [4]
855
855
  }));
856
856
  expect(error.path).to.be.eql('a/0/b/c/d/number');
@@ -876,7 +876,7 @@ describe('ArrayScheme', () => {
876
876
  } as Scheme]
877
877
  },
878
878
 
879
- message: createErrorMsg(ErrorMsg.SCHEMES_HAS_INVALID_TYPE, {
879
+ message: createErrorMsg(ERROR_MESSAGE.SCHEMES_HAS_INVALID_TYPE, {
880
880
  placeholders: [invalidDataType]
881
881
  })
882
882
  });
@@ -912,8 +912,8 @@ describe('ArrayScheme', () => {
912
912
  throw new Error('spec failed');
913
913
  }
914
914
 
915
- expect(error.type).to.be.eql(ErrorType.ITEMS_SCHEMES);
916
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ITEMS_SCHEMES, {
915
+ expect(error.type).to.be.eql(ERROR_TYPE.ITEMS_SCHEMES);
916
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ITEMS_SCHEMES, {
917
917
  placeholders: [JSON.stringify(allSchemes)]
918
918
  }));
919
919
  expect(error.path).to.be.eql('a/0');
@@ -974,8 +974,8 @@ describe('ArrayScheme', () => {
974
974
  throw new Error('spec failed');
975
975
  }
976
976
 
977
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
978
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
977
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
978
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
979
979
  placeholders: [JSON.stringify(itemScheme)]
980
980
  }));
981
981
  expect(error.path).to.be.eql('a/0/b/1');
@@ -1008,8 +1008,8 @@ describe('ArrayScheme', () => {
1008
1008
  throw new Error('spec failed');
1009
1009
  }
1010
1010
 
1011
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
1012
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
1011
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
1012
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
1013
1013
  placeholders: [JSON.stringify(itemScheme)]
1014
1014
  }));
1015
1015
  expect(error.path).to.be.eql('a/0/b/1');
@@ -4,7 +4,7 @@ import { expect } from 'chai';
4
4
  import { ejv } from '../src/ejv';
5
5
 
6
6
  import { EjvError } from '../src/interfaces';
7
- import { ErrorMsg, ErrorType } from '../src/constants';
7
+ import { ERROR_MESSAGE, ERROR_TYPE } from '../src/constants';
8
8
  import { createErrorMsg } from '../src/util';
9
9
 
10
10
 
@@ -27,8 +27,8 @@ describe('CommonScheme', () => {
27
27
  throw new Error('spec failed');
28
28
  }
29
29
 
30
- expect(error.type).to.be.eql(ErrorType.REQUIRED);
31
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.REQUIRED));
30
+ expect(error.type).to.be.eql(ERROR_TYPE.REQUIRED);
31
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.REQUIRED));
32
32
  expect(error.path).to.be.eql('a');
33
33
  expect(error.data).to.be.deep.equal(data);
34
34
  expect(error.errorData).to.be.undefined;
@@ -61,8 +61,8 @@ describe('CommonScheme', () => {
61
61
  throw new Error('spec failed');
62
62
  }
63
63
 
64
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
65
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
64
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
65
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
66
66
  placeholders: ['string']
67
67
  }));
68
68
  expect(error.path).to.be.eql('a');
@@ -89,8 +89,8 @@ describe('CommonScheme', () => {
89
89
  throw new Error('spec failed');
90
90
  }
91
91
 
92
- expect(error.type).to.be.eql(ErrorType.REQUIRED);
93
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.REQUIRED));
92
+ expect(error.type).to.be.eql(ERROR_TYPE.REQUIRED);
93
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.REQUIRED));
94
94
  expect(error.path).to.be.eql('a');
95
95
  expect(error.data).to.be.deep.equal(data);
96
96
  expect(error.errorData).to.be.undefined;
@@ -125,8 +125,8 @@ describe('CommonScheme', () => {
125
125
  throw new Error('spec failed');
126
126
  }
127
127
 
128
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
129
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
128
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
129
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
130
130
  placeholders: ['string']
131
131
  }));
132
132
  expect(error.path).to.be.eql('a');
@@ -177,8 +177,8 @@ describe('CommonScheme', () => {
177
177
  throw new Error('spec failed');
178
178
  }
179
179
 
180
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
181
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
180
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
181
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
182
182
  placeholders: ['string']
183
183
  }));
184
184
  expect(error.path).to.be.eql('a');
@@ -205,8 +205,8 @@ describe('CommonScheme', () => {
205
205
  throw new Error('spec failed');
206
206
  }
207
207
 
208
- expect(error.type).to.be.eql(ErrorType.REQUIRED);
209
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.REQUIRED));
208
+ expect(error.type).to.be.eql(ERROR_TYPE.REQUIRED);
209
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.REQUIRED));
210
210
  expect(error.path).to.be.eql('a');
211
211
  expect(error.data).to.be.deep.equal(data);
212
212
  expect(error.errorData).to.be.null;
@@ -229,8 +229,8 @@ describe('CommonScheme', () => {
229
229
  throw new Error('spec failed');
230
230
  }
231
231
 
232
- expect(error.type).to.be.eql(ErrorType.REQUIRED);
233
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.REQUIRED));
232
+ expect(error.type).to.be.eql(ERROR_TYPE.REQUIRED);
233
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.REQUIRED));
234
234
  expect(error.path).to.be.eql('a');
235
235
  expect(error.data).to.be.deep.equal(data);
236
236
  expect(error.errorData).to.be.null;
@@ -4,7 +4,7 @@ import { expect } from 'chai';
4
4
  import { ejv } from '../src/ejv';
5
5
 
6
6
  import { DateScheme, EjvError, Scheme } from '../src/interfaces';
7
- import { ErrorMsg, ErrorType } from '../src/constants';
7
+ import { ERROR_MESSAGE, ERROR_TYPE } from '../src/constants';
8
8
  import { createErrorMsg } from '../src/util';
9
9
  import { checkSchemeError, TypeTester, typeTesterArr } from './common-test-util';
10
10
 
@@ -40,7 +40,7 @@ describe('DateScheme', () => {
40
40
  type ResultDefine = {
41
41
  scheme: Partial<DateScheme>;
42
42
 
43
- error: null | keyof typeof ErrorType;
43
+ error: null | keyof typeof ERROR_TYPE;
44
44
  placeholder?: string;
45
45
  }
46
46
 
@@ -72,8 +72,8 @@ describe('DateScheme', () => {
72
72
  throw new Error('spec failed');
73
73
  }
74
74
 
75
- expect(result.type).to.be.eql(ErrorType[define.error]);
76
- expect(result.message).to.eql(createErrorMsg(ErrorMsg[define.error as keyof typeof ErrorMsg], {
75
+ expect(result.type).to.be.eql(ERROR_TYPE[define.error]);
76
+ expect(result.message).to.eql(createErrorMsg(ERROR_MESSAGE[define.error as keyof typeof ERROR_MESSAGE], {
77
77
  placeholders: [define.placeholder || '']
78
78
  }));
79
79
  expect(result.path).to.be.eql('date');
@@ -105,8 +105,8 @@ describe('DateScheme', () => {
105
105
  throw new Error('spec failed');
106
106
  }
107
107
 
108
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH);
109
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH, {
108
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH);
109
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH, {
110
110
  placeholders: ['date']
111
111
  }));
112
112
  expect(error.path).to.be.eql('a');
@@ -134,8 +134,8 @@ describe('DateScheme', () => {
134
134
  throw new Error('spec failed');
135
135
  }
136
136
 
137
- expect(error.type).to.be.eql(ErrorType.TYPE_MISMATCH_ONE_OF);
138
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.TYPE_MISMATCH_ONE_OF, {
137
+ expect(error.type).to.be.eql(ERROR_TYPE.TYPE_MISMATCH_ONE_OF);
138
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.TYPE_MISMATCH_ONE_OF, {
139
139
  placeholders: [JSON.stringify(typeArr)]
140
140
  }));
141
141
  expect(error.path).to.be.eql('a');
@@ -209,7 +209,7 @@ describe('DateScheme', () => {
209
209
  checkSchemeError({
210
210
  data,
211
211
  errorScheme,
212
- message: createErrorMsg(ErrorMsg.MIN_DATE_SHOULD_BE_DATE_OR_STRING)
212
+ message: createErrorMsg(ERROR_MESSAGE.MIN_DATE_SHOULD_BE_DATE_OR_STRING)
213
213
  });
214
214
  });
215
215
 
@@ -223,7 +223,7 @@ describe('DateScheme', () => {
223
223
  checkSchemeError({
224
224
  data,
225
225
  errorScheme,
226
- message: createErrorMsg(ErrorMsg.MIN_DATE_SHOULD_BE_DATE_OR_STRING)
226
+ message: createErrorMsg(ERROR_MESSAGE.MIN_DATE_SHOULD_BE_DATE_OR_STRING)
227
227
  });
228
228
  });
229
229
  });
@@ -238,7 +238,7 @@ describe('DateScheme', () => {
238
238
  };
239
239
 
240
240
  if ([2, 5].includes(i)) {
241
- result.error = ErrorType.AFTER_OR_SAME_DATE;
241
+ result.error = ERROR_TYPE.AFTER_OR_SAME_DATE;
242
242
  result.placeholder = one.toISOString();
243
243
  }
244
244
 
@@ -256,7 +256,7 @@ describe('DateScheme', () => {
256
256
  };
257
257
 
258
258
  if ([2, 5].includes(i)) {
259
- result.error = ErrorType.AFTER_OR_SAME_DATE;
259
+ result.error = ERROR_TYPE.AFTER_OR_SAME_DATE;
260
260
  result.placeholder = one.toISOString();
261
261
  }
262
262
 
@@ -282,7 +282,7 @@ describe('DateScheme', () => {
282
282
  checkSchemeError({
283
283
  data,
284
284
  errorScheme,
285
- message: createErrorMsg(ErrorMsg.EXCLUSIVE_MIN_SHOULD_BE_BOOLEAN)
285
+ message: createErrorMsg(ERROR_MESSAGE.EXCLUSIVE_MIN_SHOULD_BE_BOOLEAN)
286
286
  });
287
287
  });
288
288
  });
@@ -298,7 +298,7 @@ describe('DateScheme', () => {
298
298
  };
299
299
 
300
300
  if ([1, 2, 4, 5].includes(i)) {
301
- result.error = ErrorType.AFTER_DATE;
301
+ result.error = ERROR_TYPE.AFTER_DATE;
302
302
  result.placeholder = one.toISOString();
303
303
  }
304
304
 
@@ -317,7 +317,7 @@ describe('DateScheme', () => {
317
317
  };
318
318
 
319
319
  if ([2, 5].includes(i)) {
320
- result.error = ErrorType.AFTER_OR_SAME_DATE;
320
+ result.error = ERROR_TYPE.AFTER_OR_SAME_DATE;
321
321
  result.placeholder = one.toISOString();
322
322
  }
323
323
 
@@ -351,7 +351,7 @@ describe('DateScheme', () => {
351
351
  checkSchemeError({
352
352
  data,
353
353
  errorScheme,
354
- message: createErrorMsg(ErrorMsg.MAX_DATE_SHOULD_BE_DATE_OR_STRING)
354
+ message: createErrorMsg(ERROR_MESSAGE.MAX_DATE_SHOULD_BE_DATE_OR_STRING)
355
355
  });
356
356
  });
357
357
 
@@ -365,7 +365,7 @@ describe('DateScheme', () => {
365
365
  checkSchemeError({
366
366
  data,
367
367
  errorScheme,
368
- message: createErrorMsg(ErrorMsg.MAX_DATE_SHOULD_BE_DATE_OR_STRING)
368
+ message: createErrorMsg(ERROR_MESSAGE.MAX_DATE_SHOULD_BE_DATE_OR_STRING)
369
369
  });
370
370
  });
371
371
  });
@@ -380,7 +380,7 @@ describe('DateScheme', () => {
380
380
  };
381
381
 
382
382
  if ([0, 3].includes(i)) {
383
- result.error = ErrorType.BEFORE_OR_SAME_DATE;
383
+ result.error = ERROR_TYPE.BEFORE_OR_SAME_DATE;
384
384
  result.placeholder = one.toISOString();
385
385
  }
386
386
 
@@ -398,7 +398,7 @@ describe('DateScheme', () => {
398
398
  };
399
399
 
400
400
  if ([0, 3].includes(i)) {
401
- result.error = ErrorType.BEFORE_OR_SAME_DATE;
401
+ result.error = ERROR_TYPE.BEFORE_OR_SAME_DATE;
402
402
  result.placeholder = one.toISOString();
403
403
  }
404
404
 
@@ -424,7 +424,7 @@ describe('DateScheme', () => {
424
424
  checkSchemeError({
425
425
  data,
426
426
  errorScheme,
427
- message: createErrorMsg(ErrorMsg.EXCLUSIVE_MAX_SHOULD_BE_BOOLEAN)
427
+ message: createErrorMsg(ERROR_MESSAGE.EXCLUSIVE_MAX_SHOULD_BE_BOOLEAN)
428
428
  });
429
429
  });
430
430
  });
@@ -440,7 +440,7 @@ describe('DateScheme', () => {
440
440
  };
441
441
 
442
442
  if ([0, 1, 3, 4].includes(i)) {
443
- result.error = ErrorType.BEFORE_DATE;
443
+ result.error = ERROR_TYPE.BEFORE_DATE;
444
444
  result.placeholder = one.toISOString();
445
445
  }
446
446
 
@@ -459,7 +459,7 @@ describe('DateScheme', () => {
459
459
  };
460
460
 
461
461
  if ([0, 3].includes(i)) {
462
- result.error = ErrorType.BEFORE_OR_SAME_DATE;
462
+ result.error = ERROR_TYPE.BEFORE_OR_SAME_DATE;
463
463
  result.placeholder = one.toISOString();
464
464
  }
465
465