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('StringScheme', () => {
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: ['string']
37
37
  }));
38
38
  expect(error.path).to.be.eql('a');
@@ -60,8 +60,8 @@ describe('StringScheme', () => {
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');
@@ -110,101 +110,198 @@ describe('StringScheme', () => {
110
110
  });
111
111
  });
112
112
 
113
- describe('enum', () => {
114
- describe('check parameter', () => {
115
- const data = {
116
- a: 'a'
117
- };
113
+ describe('enum & notEnum', () => {
114
+ describe('enum', () => {
115
+ describe('check parameter', () => {
116
+ const data = {
117
+ a: 'a'
118
+ };
118
119
 
119
- it('undefined is ok', () => {
120
- expect(ejv(data, [{
121
- key: 'a',
122
- type: 'string',
123
- enum: undefined
124
- }])).to.be.null;
125
- });
120
+ it('undefined is ok', () => {
121
+ expect(ejv(data, [{
122
+ key: 'a',
123
+ type: 'string',
124
+ enum: undefined
125
+ }])).to.be.null;
126
+ });
126
127
 
127
- it('null', () => {
128
- const errorScheme: Scheme = {
129
- key: 'a',
130
- type: 'string',
131
- enum: null as unknown as string[]
132
- };
128
+ it('null', () => {
129
+ const errorScheme: Scheme = {
130
+ key: 'a',
131
+ type: 'string',
132
+ enum: null as unknown as string[]
133
+ };
133
134
 
134
- checkSchemeError({
135
- data,
136
- errorScheme,
137
- message: createErrorMsg(ErrorMsg.ENUM_SHOULD_BE_ARRAY)
135
+ checkSchemeError({
136
+ data,
137
+ errorScheme,
138
+ message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_ARRAY)
139
+ });
140
+ });
141
+
142
+ it('not array', () => {
143
+ const errorScheme: Scheme = {
144
+ key: 'a',
145
+ type: 'string',
146
+ enum: 'a' as unknown as string[]
147
+ };
148
+
149
+ checkSchemeError({
150
+ data,
151
+ errorScheme,
152
+ message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_ARRAY)
153
+ });
154
+ });
155
+
156
+ it('not string', () => {
157
+ const errorScheme: Scheme = {
158
+ key: 'a',
159
+ type: 'string',
160
+ enum: [10]
161
+ };
162
+
163
+ checkSchemeError({
164
+ data,
165
+ errorScheme,
166
+ message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_STRINGS)
167
+ });
138
168
  });
139
169
  });
140
170
 
141
- it('not array', () => {
142
- const errorScheme: Scheme = {
171
+ it('fail', () => {
172
+ const enumArr: string[] = ['b', 'c'];
173
+
174
+ const data = {
175
+ a: 'a'
176
+ };
177
+
178
+ const error: EjvError | null = ejv(data, [{
143
179
  key: 'a',
144
180
  type: 'string',
145
- enum: 'a' as unknown as string[]
146
- };
181
+ enum: enumArr
182
+ }]);
147
183
 
148
- checkSchemeError({
149
- data,
150
- errorScheme,
151
- message: createErrorMsg(ErrorMsg.ENUM_SHOULD_BE_ARRAY)
152
- });
184
+ expect(error).to.be.instanceof(EjvError);
185
+
186
+ if (!error) {
187
+ throw new Error('spec failed');
188
+ }
189
+
190
+ expect(error.type).to.be.eql(ERROR_TYPE.ONE_VALUE_OF);
191
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ONE_VALUE_OF, {
192
+ placeholders: [JSON.stringify(enumArr)]
193
+ }));
194
+ expect(error.path).to.be.eql('a');
195
+ expect(error.data).to.be.deep.equal(data);
196
+ expect(error.errorData).to.be.eql('a');
153
197
  });
154
198
 
155
- it('not string', () => {
156
- const errorScheme: Scheme = {
199
+ it('ok', () => {
200
+ expect(ejv({
201
+ a: 'a'
202
+ }, [{
157
203
  key: 'a',
158
204
  type: 'string',
159
- enum: [10]
205
+ enum: ['a', 'b', 'c']
206
+ }])).to.be.null;
207
+ });
208
+ });
209
+
210
+ describe('notEnum', () => {
211
+ describe('check parameter', () => {
212
+ const data = {
213
+ a: 'a'
160
214
  };
161
215
 
162
- checkSchemeError({
163
- data,
164
- errorScheme,
165
- message: createErrorMsg(ErrorMsg.ENUM_SHOULD_BE_STRINGS)
216
+ it('undefined is ok', () => {
217
+ expect(ejv(data, [{
218
+ key: 'a',
219
+ type: 'string',
220
+ notEnum: undefined
221
+ }])).to.be.null;
222
+ });
223
+
224
+ it('null', () => {
225
+ const errorScheme: Scheme = {
226
+ key: 'a',
227
+ type: 'string',
228
+ notEnum: null as unknown as string[]
229
+ };
230
+
231
+ checkSchemeError({
232
+ data,
233
+ errorScheme,
234
+ message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_ARRAY)
235
+ });
236
+ });
237
+
238
+ it('not array', () => {
239
+ const errorScheme: Scheme = {
240
+ key: 'a',
241
+ type: 'string',
242
+ notEnum: 'a' as unknown as string[]
243
+ };
244
+
245
+ checkSchemeError({
246
+ data,
247
+ errorScheme,
248
+ message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_ARRAY)
249
+ });
250
+ });
251
+
252
+ it('not string', () => {
253
+ const errorScheme: Scheme = {
254
+ key: 'a',
255
+ type: 'string',
256
+ notEnum: [10]
257
+ };
258
+
259
+ checkSchemeError({
260
+ data,
261
+ errorScheme,
262
+ message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_STRINGS)
263
+ });
166
264
  });
167
265
  });
168
- });
169
266
 
170
- it('fail', () => {
171
- const enumArr: string[] = ['b', 'c'];
267
+ it('fail', () => {
268
+ const enumArr: string[] = ['a', 'b', 'c'];
172
269
 
173
- const data = {
174
- a: 'a'
175
- };
270
+ const data = {
271
+ a: 'a'
272
+ };
176
273
 
177
- const error: EjvError | null = ejv(data, [{
178
- key: 'a',
179
- type: 'string',
180
- enum: enumArr
181
- }]);
274
+ const error: EjvError | null = ejv(data, [{
275
+ key: 'a',
276
+ type: 'string',
277
+ notEnum: enumArr
278
+ }]);
182
279
 
183
- expect(error).to.be.instanceof(EjvError);
280
+ expect(error).to.be.instanceof(EjvError);
184
281
 
185
- if (!error) {
186
- throw new Error('spec failed');
187
- }
282
+ if (!error) {
283
+ throw new Error('spec failed');
284
+ }
188
285
 
189
- expect(error.type).to.be.eql(ErrorType.ONE_VALUE_OF);
190
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.ONE_VALUE_OF, {
191
- placeholders: [JSON.stringify(enumArr)]
192
- }));
193
- expect(error.path).to.be.eql('a');
194
- expect(error.data).to.be.deep.equal(data);
195
- expect(error.errorData).to.be.eql('a');
196
- });
286
+ expect(error.type).to.be.eql(ERROR_TYPE.NOT_ONE_VALUE_OF);
287
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.NOT_ONE_VALUE_OF, {
288
+ placeholders: [JSON.stringify(enumArr)]
289
+ }));
290
+ expect(error.path).to.be.eql('a');
291
+ expect(error.data).to.be.deep.equal(data);
292
+ expect(error.errorData).to.be.eql('a');
293
+ });
197
294
 
198
- it('ok', () => {
199
- expect(ejv({
200
- a: 'a'
201
- }, [{
202
- key: 'a',
203
- type: 'string',
204
- enum: ['a', 'b', 'c']
205
- }])).to.be.null;
295
+ it('ok', () => {
296
+ expect(ejv({
297
+ a: 'a'
298
+ }, [{
299
+ key: 'a',
300
+ type: 'string',
301
+ notEnum: ['b', 'c']
302
+ }])).to.be.null;
303
+ });
206
304
  });
207
-
208
305
  });
209
306
 
210
307
  describe('length', () => {
@@ -231,7 +328,7 @@ describe('StringScheme', () => {
231
328
  checkSchemeError({
232
329
  data,
233
330
  errorScheme,
234
- message: createErrorMsg(ErrorMsg.LENGTH_SHOULD_BE_INTEGER)
331
+ message: createErrorMsg(ERROR_MESSAGE.LENGTH_SHOULD_BE_INTEGER)
235
332
  });
236
333
  });
237
334
 
@@ -245,7 +342,7 @@ describe('StringScheme', () => {
245
342
  checkSchemeError({
246
343
  data,
247
344
  errorScheme,
248
- message: createErrorMsg(ErrorMsg.LENGTH_SHOULD_BE_INTEGER)
345
+ message: createErrorMsg(ERROR_MESSAGE.LENGTH_SHOULD_BE_INTEGER)
249
346
  });
250
347
  });
251
348
  });
@@ -278,8 +375,8 @@ describe('StringScheme', () => {
278
375
  throw new Error('spec failed');
279
376
  }
280
377
 
281
- expect(error.type).to.be.eql(ErrorType.LENGTH);
282
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.LENGTH, {
378
+ expect(error.type).to.be.eql(ERROR_TYPE.LENGTH);
379
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.LENGTH, {
283
380
  placeholders: [4]
284
381
  }));
285
382
  expect(error.path).to.be.eql('a');
@@ -311,7 +408,7 @@ describe('StringScheme', () => {
311
408
  checkSchemeError({
312
409
  data,
313
410
  errorScheme,
314
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
411
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
315
412
  });
316
413
  });
317
414
 
@@ -325,7 +422,7 @@ describe('StringScheme', () => {
325
422
  checkSchemeError({
326
423
  data,
327
424
  errorScheme,
328
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
425
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
329
426
  });
330
427
  });
331
428
 
@@ -339,7 +436,7 @@ describe('StringScheme', () => {
339
436
  checkSchemeError({
340
437
  data,
341
438
  errorScheme,
342
- message: createErrorMsg(ErrorMsg.MIN_LENGTH_SHOULD_BE_INTEGER)
439
+ message: createErrorMsg(ERROR_MESSAGE.MIN_LENGTH_SHOULD_BE_INTEGER)
343
440
  });
344
441
  });
345
442
  });
@@ -379,8 +476,8 @@ describe('StringScheme', () => {
379
476
  throw new Error('spec failed');
380
477
  }
381
478
 
382
- expect(error.type).to.be.eql(ErrorType.MIN_LENGTH);
383
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.MIN_LENGTH, {
479
+ expect(error.type).to.be.eql(ERROR_TYPE.MIN_LENGTH);
480
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.MIN_LENGTH, {
384
481
  placeholders: [4]
385
482
  }));
386
483
  expect(error.path).to.be.eql('a');
@@ -413,7 +510,7 @@ describe('StringScheme', () => {
413
510
  checkSchemeError({
414
511
  data,
415
512
  errorScheme,
416
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
513
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
417
514
  });
418
515
  });
419
516
 
@@ -427,7 +524,7 @@ describe('StringScheme', () => {
427
524
  checkSchemeError({
428
525
  data,
429
526
  errorScheme,
430
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
527
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
431
528
  });
432
529
  });
433
530
 
@@ -441,7 +538,7 @@ describe('StringScheme', () => {
441
538
  checkSchemeError({
442
539
  data,
443
540
  errorScheme,
444
- message: createErrorMsg(ErrorMsg.MAX_LENGTH_SHOULD_BE_INTEGER)
541
+ message: createErrorMsg(ERROR_MESSAGE.MAX_LENGTH_SHOULD_BE_INTEGER)
445
542
  });
446
543
  });
447
544
  });
@@ -463,8 +560,8 @@ describe('StringScheme', () => {
463
560
  throw new Error('spec failed');
464
561
  }
465
562
 
466
- expect(error.type).to.be.eql(ErrorType.MAX_LENGTH);
467
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.MAX_LENGTH, {
563
+ expect(error.type).to.be.eql(ERROR_TYPE.MAX_LENGTH);
564
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.MAX_LENGTH, {
468
565
  placeholders: [2]
469
566
  }));
470
567
  expect(error.path).to.be.eql('a');
@@ -515,7 +612,7 @@ describe('StringScheme', () => {
515
612
  checkSchemeError({
516
613
  data,
517
614
  errorScheme,
518
- message: createErrorMsg(ErrorMsg.INVALID_STRING_FORMAT, {
615
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_FORMAT, {
519
616
  placeholders: ['null']
520
617
  })
521
618
  });
@@ -532,7 +629,7 @@ describe('StringScheme', () => {
532
629
  checkSchemeError({
533
630
  data,
534
631
  errorScheme,
535
- message: createErrorMsg(ErrorMsg.INVALID_STRING_FORMAT, {
632
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_FORMAT, {
536
633
  placeholders: ['invalidStringFormat']
537
634
  })
538
635
  });
@@ -548,7 +645,7 @@ describe('StringScheme', () => {
548
645
  checkSchemeError({
549
646
  data,
550
647
  errorScheme,
551
- message: createErrorMsg(ErrorMsg.INVALID_STRING_FORMAT, {
648
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_FORMAT, {
552
649
  placeholders: ['invalidStringFormat']
553
650
  })
554
651
  });
@@ -574,8 +671,8 @@ describe('StringScheme', () => {
574
671
  throw new Error('spec failed');
575
672
  }
576
673
 
577
- expect(error.type).to.be.eql(ErrorType.FORMAT);
578
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT, {
674
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT);
675
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
579
676
  placeholders: ['email']
580
677
  }));
581
678
  expect(error.path).to.be.eql('a');
@@ -610,8 +707,8 @@ describe('StringScheme', () => {
610
707
  throw new Error('spec failed');
611
708
  }
612
709
 
613
- expect(error.type).to.be.eql(ErrorType.FORMAT_ONE_OF);
614
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT_ONE_OF, {
710
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
711
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
615
712
  placeholders: [JSON.stringify(formatArr)]
616
713
  }));
617
714
  expect(error.path).to.be.eql('a');
@@ -647,8 +744,8 @@ describe('StringScheme', () => {
647
744
  throw new Error('spec failed');
648
745
  }
649
746
 
650
- expect(error.type).to.be.eql(ErrorType.FORMAT);
651
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT, {
747
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT);
748
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
652
749
  placeholders: ['date']
653
750
  }));
654
751
  expect(error.path).to.be.eql('a');
@@ -683,8 +780,8 @@ describe('StringScheme', () => {
683
780
  throw new Error('spec failed');
684
781
  }
685
782
 
686
- expect(error.type).to.be.eql(ErrorType.FORMAT_ONE_OF);
687
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT_ONE_OF, {
783
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
784
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
688
785
  placeholders: [JSON.stringify(formatArr)]
689
786
  }));
690
787
  expect(error.path).to.be.eql('a');
@@ -719,8 +816,8 @@ describe('StringScheme', () => {
719
816
  throw new Error('spec failed');
720
817
  }
721
818
 
722
- expect(error.type).to.be.eql(ErrorType.FORMAT);
723
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT, {
819
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT);
820
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
724
821
  placeholders: ['time']
725
822
  }));
726
823
  expect(error.path).to.be.eql('a');
@@ -755,8 +852,8 @@ describe('StringScheme', () => {
755
852
  throw new Error('spec failed');
756
853
  }
757
854
 
758
- expect(error.type).to.be.eql(ErrorType.FORMAT_ONE_OF);
759
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT_ONE_OF, {
855
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
856
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
760
857
  placeholders: [JSON.stringify(formatArr)]
761
858
  }));
762
859
  expect(error.path).to.be.eql('a');
@@ -791,8 +888,8 @@ describe('StringScheme', () => {
791
888
  throw new Error('spec failed');
792
889
  }
793
890
 
794
- expect(error.type).to.be.eql(ErrorType.FORMAT);
795
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT, {
891
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT);
892
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
796
893
  placeholders: ['date-time']
797
894
  }));
798
895
  expect(error.path).to.be.eql('a');
@@ -843,8 +940,8 @@ describe('StringScheme', () => {
843
940
  throw new Error('spec failed');
844
941
  }
845
942
 
846
- expect(error.type).to.be.eql(ErrorType.FORMAT_ONE_OF);
847
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.FORMAT_ONE_OF, {
943
+ expect(error.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
944
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
848
945
  placeholders: [JSON.stringify(formatArr)]
849
946
  }));
850
947
  expect(error.path).to.be.eql('a');
@@ -902,7 +999,7 @@ describe('StringScheme', () => {
902
999
  checkSchemeError({
903
1000
  data,
904
1001
  errorScheme,
905
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1002
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
906
1003
  placeholders: ['null']
907
1004
  })
908
1005
  });
@@ -918,7 +1015,7 @@ describe('StringScheme', () => {
918
1015
  checkSchemeError({
919
1016
  data,
920
1017
  errorScheme,
921
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1018
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
922
1019
  placeholders: ['1']
923
1020
  })
924
1021
  });
@@ -934,7 +1031,7 @@ describe('StringScheme', () => {
934
1031
  checkSchemeError({
935
1032
  data,
936
1033
  errorScheme,
937
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1034
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
938
1035
  placeholders: ['//']
939
1036
  })
940
1037
  });
@@ -950,7 +1047,7 @@ describe('StringScheme', () => {
950
1047
  checkSchemeError({
951
1048
  data,
952
1049
  errorScheme,
953
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1050
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
954
1051
  placeholders: ['[]']
955
1052
  })
956
1053
  });
@@ -966,7 +1063,7 @@ describe('StringScheme', () => {
966
1063
  checkSchemeError({
967
1064
  data,
968
1065
  errorScheme,
969
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1066
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
970
1067
  placeholders: ['[/null/, /ab/]']
971
1068
  })
972
1069
  });
@@ -982,7 +1079,7 @@ describe('StringScheme', () => {
982
1079
  checkSchemeError({
983
1080
  data,
984
1081
  errorScheme,
985
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1082
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
986
1083
  placeholders: ['[1, 3]']
987
1084
  })
988
1085
  });
@@ -998,7 +1095,7 @@ describe('StringScheme', () => {
998
1095
  checkSchemeError({
999
1096
  data,
1000
1097
  errorScheme,
1001
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1098
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
1002
1099
  placeholders: ['[//]']
1003
1100
  })
1004
1101
  });
@@ -1014,7 +1111,7 @@ describe('StringScheme', () => {
1014
1111
  checkSchemeError({
1015
1112
  data,
1016
1113
  errorScheme,
1017
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1114
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
1018
1115
  placeholders: ['//']
1019
1116
  })
1020
1117
  });
@@ -1030,7 +1127,7 @@ describe('StringScheme', () => {
1030
1127
  checkSchemeError({
1031
1128
  data,
1032
1129
  errorScheme,
1033
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1130
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
1034
1131
  placeholders: ['/null/']
1035
1132
  })
1036
1133
  });
@@ -1046,7 +1143,7 @@ describe('StringScheme', () => {
1046
1143
  checkSchemeError({
1047
1144
  data,
1048
1145
  errorScheme,
1049
- message: createErrorMsg(ErrorMsg.INVALID_STRING_PATTERN, {
1146
+ message: createErrorMsg(ERROR_MESSAGE.INVALID_STRING_PATTERN, {
1050
1147
  placeholders: ['[//]']
1051
1148
  })
1052
1149
  });
@@ -1078,8 +1175,8 @@ describe('StringScheme', () => {
1078
1175
  throw new Error('spec failed');
1079
1176
  }
1080
1177
 
1081
- expect(error.type).to.be.eql(ErrorType.PATTERN);
1082
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.PATTERN, {
1178
+ expect(error.type).to.be.eql(ERROR_TYPE.PATTERN);
1179
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.PATTERN, {
1083
1180
  placeholders: ['/ac/']
1084
1181
  }));
1085
1182
  expect(error.path).to.be.eql('a');
@@ -1124,8 +1221,8 @@ describe('StringScheme', () => {
1124
1221
  throw new Error('spec failed');
1125
1222
  }
1126
1223
 
1127
- expect(error.type).to.be.eql(ErrorType.PATTERN_ONE_OF);
1128
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.PATTERN_ONE_OF, {
1224
+ expect(error.type).to.be.eql(ERROR_TYPE.PATTERN_ONE_OF);
1225
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.PATTERN_ONE_OF, {
1129
1226
  placeholders: ['[/abcc/, /ac/]']
1130
1227
  }));
1131
1228
  expect(error.path).to.be.eql('a');
@@ -1158,8 +1255,8 @@ describe('StringScheme', () => {
1158
1255
  throw new Error('spec failed');
1159
1256
  }
1160
1257
 
1161
- expect(error.type).to.be.eql(ErrorType.PATTERN);
1162
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.PATTERN, {
1258
+ expect(error.type).to.be.eql(ERROR_TYPE.PATTERN);
1259
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.PATTERN, {
1163
1260
  placeholders: [/ac/.toString()]
1164
1261
  }));
1165
1262
  expect(error.path).to.be.eql('a');
@@ -1204,8 +1301,8 @@ describe('StringScheme', () => {
1204
1301
  throw new Error('spec failed');
1205
1302
  }
1206
1303
 
1207
- expect(error.type).to.be.eql(ErrorType.PATTERN_ONE_OF);
1208
- expect(error.message).to.be.eql(createErrorMsg(ErrorMsg.PATTERN_ONE_OF, {
1304
+ expect(error.type).to.be.eql(ERROR_TYPE.PATTERN_ONE_OF);
1305
+ expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.PATTERN_ONE_OF, {
1209
1306
  placeholders: ['[/abcc/, /ac/]']
1210
1307
  }));
1211
1308
  expect(error.path).to.be.eql('a');
@@ -4,7 +4,7 @@ import { expect } from 'chai';
4
4
 
5
5
  import { EjvError, Scheme } from '../src/interfaces';
6
6
  import { ejv } from '../src/ejv';
7
- import { ErrorType } from '../src/constants';
7
+ import { ERROR_TYPE } from '../src/constants';
8
8
 
9
9
  export const commonTestRunner = (
10
10
  testFnc: (args: unknown) => unknown,
@@ -49,7 +49,7 @@ export const checkSchemeError = (param: {
49
49
  const ejvError: EjvError | null = ejv(param.data, [param.errorScheme]);
50
50
 
51
51
  expect(ejvError).to.be.instanceOf(EjvError);
52
- expect(ejvError).to.have.property('type', ErrorType.INVALID_SCHEMES);
52
+ expect(ejvError).to.have.property('type', ERROR_TYPE.INVALID_SCHEMES);
53
53
  expect(ejvError).to.have.property('message', param.message);
54
54
 
55
55
  expect(ejvError).to.have.property('data', param.data);