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.
- package/.mocharc.json +1 -1
- package/CHANGELOG.md +26 -0
- package/README-KR.md +166 -165
- package/README.md +182 -178
- package/build/cjs/constants.js +112 -107
- package/build/cjs/constants.js.map +1 -1
- package/build/cjs/ejv.js +245 -177
- package/build/cjs/ejv.js.map +1 -1
- package/build/cjs/index.js +6 -6
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/interfaces.js.map +1 -1
- package/build/cjs/tester.js +12 -8
- package/build/cjs/tester.js.map +1 -1
- package/build/cjs/util.js.map +1 -1
- package/build/constants.d.ts +10 -5
- package/build/esm/constants.js +111 -106
- package/build/esm/constants.js.map +1 -1
- package/build/esm/ejv.js +247 -179
- package/build/esm/ejv.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/interfaces.js.map +1 -1
- package/build/esm/tester.js +11 -8
- package/build/esm/tester.js.map +1 -1
- package/build/esm/util.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/interfaces.d.ts +10 -9
- package/build/tester.d.ts +4 -3
- package/build/util.d.ts +2 -2
- package/eslint.config.mjs +59 -0
- package/package.json +17 -13
- package/spec/ArrayScheme.ts +46 -46
- package/spec/CommonScheme.ts +15 -15
- package/spec/DateScheme.ts +22 -22
- package/spec/NumberScheme.ts +229 -121
- package/spec/ObjectScheme.ts +22 -22
- package/spec/RegExpScheme.ts +5 -5
- package/spec/StringScheme.ts +223 -126
- package/spec/common-test-util.ts +2 -2
- package/spec/ejv.spec.ts +20 -20
- package/spec/testers.spec.ts +5 -5
- package/src/constants.ts +12 -5
- package/src/ejv.ts +291 -202
- package/src/index.ts +1 -1
- package/src/interfaces.ts +11 -12
- package/src/tester.ts +14 -10
- package/src/util.ts +2 -2
- package/tsconfig.json +2 -1
- package/.eslintrc.json +0 -88
package/spec/NumberScheme.ts
CHANGED
|
@@ -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 {
|
|
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('NumberScheme', () => {
|
|
|
31
31
|
throw new Error('spec failed');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
expect(error.type).to.be.eql(
|
|
35
|
-
expect(error.message).to.be.eql(createErrorMsg(
|
|
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: ['number']
|
|
37
37
|
}));
|
|
38
38
|
expect(error.path).to.be.eql('a');
|
|
@@ -60,8 +60,8 @@ describe('NumberScheme', () => {
|
|
|
60
60
|
throw new Error('spec failed');
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
expect(error.type).to.be.eql(
|
|
64
|
-
expect(error.message).to.be.eql(createErrorMsg(
|
|
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,109 +110,217 @@ describe('NumberScheme', () => {
|
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
describe('enum', () => {
|
|
114
|
-
describe('
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
describe('enum & notEnum', () => {
|
|
114
|
+
describe('enum', () => {
|
|
115
|
+
describe('check parameter', () => {
|
|
116
|
+
it('undefined is ok', () => {
|
|
117
|
+
expect(ejv({
|
|
118
|
+
a: 1
|
|
119
|
+
}, [{
|
|
120
|
+
key: 'a',
|
|
121
|
+
type: 'number',
|
|
122
|
+
enum: undefined
|
|
123
|
+
}])).to.be.null;
|
|
124
|
+
});
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
it('null', () => {
|
|
127
|
+
const data = {
|
|
128
|
+
a: 1
|
|
129
|
+
};
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
const errorScheme: Scheme = {
|
|
132
|
+
key: 'a',
|
|
133
|
+
type: 'number',
|
|
134
|
+
enum: null as unknown as number[]
|
|
135
|
+
};
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
checkSchemeError({
|
|
138
|
+
data,
|
|
139
|
+
errorScheme,
|
|
140
|
+
message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_ARRAY)
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('not array', () => {
|
|
145
|
+
const data = {
|
|
146
|
+
a: 10
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const errorScheme: Scheme = {
|
|
150
|
+
key: 'a',
|
|
151
|
+
type: 'number',
|
|
152
|
+
enum: 1 as unknown as number[]
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
checkSchemeError({
|
|
156
|
+
data,
|
|
157
|
+
errorScheme,
|
|
158
|
+
message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_ARRAY)
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('not number', () => {
|
|
163
|
+
const data = {
|
|
164
|
+
a: 10
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const errorScheme: Scheme = {
|
|
168
|
+
key: 'a',
|
|
169
|
+
type: 'number',
|
|
170
|
+
enum: ['10']
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
checkSchemeError({
|
|
174
|
+
data,
|
|
175
|
+
errorScheme,
|
|
176
|
+
message: createErrorMsg(ERROR_MESSAGE.ENUM_SHOULD_BE_NUMBERS)
|
|
177
|
+
});
|
|
140
178
|
});
|
|
141
179
|
});
|
|
142
180
|
|
|
143
|
-
it('
|
|
181
|
+
it('fail', () => {
|
|
182
|
+
const enumArr: number[] = [9, 11];
|
|
183
|
+
|
|
144
184
|
const data = {
|
|
145
185
|
a: 10
|
|
146
186
|
};
|
|
147
187
|
|
|
148
|
-
const
|
|
188
|
+
const error: EjvError | null = ejv(data, [{
|
|
149
189
|
key: 'a',
|
|
150
190
|
type: 'number',
|
|
151
|
-
enum:
|
|
152
|
-
};
|
|
191
|
+
enum: enumArr
|
|
192
|
+
}]);
|
|
153
193
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
194
|
+
expect(error).to.be.instanceof(EjvError);
|
|
195
|
+
|
|
196
|
+
if (!error) {
|
|
197
|
+
throw new Error('spec failed');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
expect(error.type).to.be.eql(ERROR_TYPE.ONE_VALUE_OF);
|
|
201
|
+
expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.ONE_VALUE_OF, {
|
|
202
|
+
placeholders: [JSON.stringify(enumArr)]
|
|
203
|
+
}));
|
|
204
|
+
expect(error.path).to.be.eql('a');
|
|
205
|
+
expect(error.data).to.be.deep.equal(data);
|
|
206
|
+
expect(error.errorData).to.be.eql(10);
|
|
159
207
|
});
|
|
160
208
|
|
|
161
|
-
it('
|
|
162
|
-
|
|
209
|
+
it('ok', () => {
|
|
210
|
+
expect(ejv({
|
|
163
211
|
a: 10
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const errorScheme: Scheme = {
|
|
212
|
+
}, [{
|
|
167
213
|
key: 'a',
|
|
168
214
|
type: 'number',
|
|
169
|
-
enum: [
|
|
170
|
-
};
|
|
215
|
+
enum: [9, 10, 11]
|
|
216
|
+
}])).to.be.null;
|
|
217
|
+
});
|
|
218
|
+
});
|
|
171
219
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
220
|
+
describe('notEnum', () => {
|
|
221
|
+
describe('check parameter', () => {
|
|
222
|
+
it('undefined is ok', () => {
|
|
223
|
+
expect(ejv({
|
|
224
|
+
a: 1
|
|
225
|
+
}, [{
|
|
226
|
+
key: 'a',
|
|
227
|
+
type: 'number',
|
|
228
|
+
notEnum: undefined
|
|
229
|
+
}])).to.be.null;
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it('null', () => {
|
|
233
|
+
const data = {
|
|
234
|
+
a: 1
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const errorScheme: Scheme = {
|
|
238
|
+
key: 'a',
|
|
239
|
+
type: 'number',
|
|
240
|
+
notEnum: null as unknown as number[]
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
checkSchemeError({
|
|
244
|
+
data,
|
|
245
|
+
errorScheme,
|
|
246
|
+
message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_ARRAY)
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('not array', () => {
|
|
251
|
+
const data = {
|
|
252
|
+
a: 10
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const errorScheme: Scheme = {
|
|
256
|
+
key: 'a',
|
|
257
|
+
type: 'number',
|
|
258
|
+
notEnum: 1 as unknown as number[]
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
checkSchemeError({
|
|
262
|
+
data,
|
|
263
|
+
errorScheme,
|
|
264
|
+
message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_ARRAY)
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('not number', () => {
|
|
269
|
+
const data = {
|
|
270
|
+
a: 10
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const errorScheme: Scheme = {
|
|
274
|
+
key: 'a',
|
|
275
|
+
type: 'number',
|
|
276
|
+
notEnum: ['10']
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
checkSchemeError({
|
|
280
|
+
data,
|
|
281
|
+
errorScheme,
|
|
282
|
+
message: createErrorMsg(ERROR_MESSAGE.NOT_ENUM_SHOULD_BE_NUMBERS)
|
|
283
|
+
});
|
|
176
284
|
});
|
|
177
285
|
});
|
|
178
|
-
});
|
|
179
286
|
|
|
180
|
-
|
|
181
|
-
|
|
287
|
+
it('fail', () => {
|
|
288
|
+
const enumArr: number[] = [9, 10, 11];
|
|
182
289
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
290
|
+
const data = {
|
|
291
|
+
a: 9
|
|
292
|
+
};
|
|
186
293
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
294
|
+
const error: EjvError | null = ejv(data, [{
|
|
295
|
+
key: 'a',
|
|
296
|
+
type: 'number',
|
|
297
|
+
notEnum: enumArr
|
|
298
|
+
}]);
|
|
192
299
|
|
|
193
|
-
|
|
300
|
+
expect(error).to.be.instanceof(EjvError);
|
|
194
301
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
302
|
+
if (!error) {
|
|
303
|
+
throw new Error('spec failed');
|
|
304
|
+
}
|
|
198
305
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
306
|
+
expect(error.type).to.be.eql(ERROR_TYPE.NOT_ONE_VALUE_OF);
|
|
307
|
+
expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.NOT_ONE_VALUE_OF, {
|
|
308
|
+
placeholders: [JSON.stringify(enumArr)]
|
|
309
|
+
}));
|
|
310
|
+
expect(error.path).to.be.eql('a');
|
|
311
|
+
expect(error.data).to.be.deep.equal(data);
|
|
312
|
+
expect(error.errorData).to.be.eql(9);
|
|
313
|
+
});
|
|
207
314
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
315
|
+
it('ok', () => {
|
|
316
|
+
expect(ejv({
|
|
317
|
+
a: 8
|
|
318
|
+
}, [{
|
|
319
|
+
key: 'a',
|
|
320
|
+
type: 'number',
|
|
321
|
+
notEnum: [9, 10, 11]
|
|
322
|
+
}])).to.be.null;
|
|
323
|
+
});
|
|
216
324
|
});
|
|
217
325
|
});
|
|
218
326
|
|
|
@@ -243,7 +351,7 @@ describe('NumberScheme', () => {
|
|
|
243
351
|
checkSchemeError({
|
|
244
352
|
data,
|
|
245
353
|
errorScheme,
|
|
246
|
-
message: createErrorMsg(
|
|
354
|
+
message: createErrorMsg(ERROR_MESSAGE.MIN_SHOULD_BE_NUMBER)
|
|
247
355
|
});
|
|
248
356
|
});
|
|
249
357
|
|
|
@@ -261,7 +369,7 @@ describe('NumberScheme', () => {
|
|
|
261
369
|
checkSchemeError({
|
|
262
370
|
data,
|
|
263
371
|
errorScheme,
|
|
264
|
-
message: createErrorMsg(
|
|
372
|
+
message: createErrorMsg(ERROR_MESSAGE.MIN_SHOULD_BE_NUMBER)
|
|
265
373
|
});
|
|
266
374
|
});
|
|
267
375
|
|
|
@@ -291,8 +399,8 @@ describe('NumberScheme', () => {
|
|
|
291
399
|
throw new Error('spec failed');
|
|
292
400
|
}
|
|
293
401
|
|
|
294
|
-
expect(error1.type).to.be.eql(
|
|
295
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
402
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.BIGGER_THAN_OR_EQUAL);
|
|
403
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN_OR_EQUAL, {
|
|
296
404
|
placeholders: [10]
|
|
297
405
|
}));
|
|
298
406
|
|
|
@@ -331,7 +439,7 @@ describe('NumberScheme', () => {
|
|
|
331
439
|
checkSchemeError({
|
|
332
440
|
data,
|
|
333
441
|
errorScheme,
|
|
334
|
-
message: createErrorMsg(
|
|
442
|
+
message: createErrorMsg(ERROR_MESSAGE.EXCLUSIVE_MIN_SHOULD_BE_BOOLEAN)
|
|
335
443
|
});
|
|
336
444
|
});
|
|
337
445
|
});
|
|
@@ -352,8 +460,8 @@ describe('NumberScheme', () => {
|
|
|
352
460
|
throw new Error('spec failed');
|
|
353
461
|
}
|
|
354
462
|
|
|
355
|
-
expect(error1.type).to.be.eql(
|
|
356
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
463
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.BIGGER_THAN);
|
|
464
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN, {
|
|
357
465
|
placeholders: [10]
|
|
358
466
|
}));
|
|
359
467
|
|
|
@@ -372,8 +480,8 @@ describe('NumberScheme', () => {
|
|
|
372
480
|
throw new Error('spec failed');
|
|
373
481
|
}
|
|
374
482
|
|
|
375
|
-
expect(error2.type).to.be.eql(
|
|
376
|
-
expect(error2.message).to.be.eql(createErrorMsg(
|
|
483
|
+
expect(error2.type).to.be.eql(ERROR_TYPE.BIGGER_THAN);
|
|
484
|
+
expect(error2.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN, {
|
|
377
485
|
placeholders: [10]
|
|
378
486
|
}));
|
|
379
487
|
|
|
@@ -403,8 +511,8 @@ describe('NumberScheme', () => {
|
|
|
403
511
|
throw new Error('spec failed');
|
|
404
512
|
}
|
|
405
513
|
|
|
406
|
-
expect(error1.type).to.be.eql(
|
|
407
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
514
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.BIGGER_THAN_OR_EQUAL);
|
|
515
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.BIGGER_THAN_OR_EQUAL, {
|
|
408
516
|
placeholders: [10]
|
|
409
517
|
}));
|
|
410
518
|
|
|
@@ -456,7 +564,7 @@ describe('NumberScheme', () => {
|
|
|
456
564
|
checkSchemeError({
|
|
457
565
|
data,
|
|
458
566
|
errorScheme,
|
|
459
|
-
message: createErrorMsg(
|
|
567
|
+
message: createErrorMsg(ERROR_MESSAGE.MAX_SHOULD_BE_NUMBER)
|
|
460
568
|
});
|
|
461
569
|
});
|
|
462
570
|
|
|
@@ -474,7 +582,7 @@ describe('NumberScheme', () => {
|
|
|
474
582
|
checkSchemeError({
|
|
475
583
|
data,
|
|
476
584
|
errorScheme,
|
|
477
|
-
message: createErrorMsg(
|
|
585
|
+
message: createErrorMsg(ERROR_MESSAGE.MAX_SHOULD_BE_NUMBER)
|
|
478
586
|
});
|
|
479
587
|
});
|
|
480
588
|
|
|
@@ -520,8 +628,8 @@ describe('NumberScheme', () => {
|
|
|
520
628
|
throw new Error('spec failed');
|
|
521
629
|
}
|
|
522
630
|
|
|
523
|
-
expect(error1.type).to.be.eql(
|
|
524
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
631
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.SMALLER_THAN_OR_EQUAL);
|
|
632
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.SMALLER_THAN_OR_EQUAL, {
|
|
525
633
|
placeholders: [10]
|
|
526
634
|
}));
|
|
527
635
|
});
|
|
@@ -544,7 +652,7 @@ describe('NumberScheme', () => {
|
|
|
544
652
|
checkSchemeError({
|
|
545
653
|
data,
|
|
546
654
|
errorScheme,
|
|
547
|
-
message: createErrorMsg(
|
|
655
|
+
message: createErrorMsg(ERROR_MESSAGE.EXCLUSIVE_MAX_SHOULD_BE_BOOLEAN)
|
|
548
656
|
});
|
|
549
657
|
});
|
|
550
658
|
});
|
|
@@ -574,8 +682,8 @@ describe('NumberScheme', () => {
|
|
|
574
682
|
throw new Error('spec failed');
|
|
575
683
|
}
|
|
576
684
|
|
|
577
|
-
expect(error1.type).to.be.eql(
|
|
578
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
685
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.SMALLER_THAN);
|
|
686
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.SMALLER_THAN, {
|
|
579
687
|
placeholders: [10]
|
|
580
688
|
}));
|
|
581
689
|
|
|
@@ -594,8 +702,8 @@ describe('NumberScheme', () => {
|
|
|
594
702
|
throw new Error('spec failed');
|
|
595
703
|
}
|
|
596
704
|
|
|
597
|
-
expect(error2.type).to.be.eql(
|
|
598
|
-
expect(error2.message).to.be.eql(createErrorMsg(
|
|
705
|
+
expect(error2.type).to.be.eql(ERROR_TYPE.SMALLER_THAN);
|
|
706
|
+
expect(error2.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.SMALLER_THAN, {
|
|
599
707
|
placeholders: [10]
|
|
600
708
|
}));
|
|
601
709
|
});
|
|
@@ -634,8 +742,8 @@ describe('NumberScheme', () => {
|
|
|
634
742
|
throw new Error('spec failed');
|
|
635
743
|
}
|
|
636
744
|
|
|
637
|
-
expect(error1.type).to.be.eql(
|
|
638
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
745
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.SMALLER_THAN_OR_EQUAL);
|
|
746
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.SMALLER_THAN_OR_EQUAL, {
|
|
639
747
|
placeholders: [10]
|
|
640
748
|
}));
|
|
641
749
|
});
|
|
@@ -668,7 +776,7 @@ describe('NumberScheme', () => {
|
|
|
668
776
|
checkSchemeError({
|
|
669
777
|
data,
|
|
670
778
|
errorScheme,
|
|
671
|
-
message: createErrorMsg(
|
|
779
|
+
message: createErrorMsg(ERROR_MESSAGE.INVALID_NUMBER_FORMAT, {
|
|
672
780
|
placeholders: ['null']
|
|
673
781
|
})
|
|
674
782
|
});
|
|
@@ -689,7 +797,7 @@ describe('NumberScheme', () => {
|
|
|
689
797
|
checkSchemeError({
|
|
690
798
|
data,
|
|
691
799
|
errorScheme,
|
|
692
|
-
message: createErrorMsg(
|
|
800
|
+
message: createErrorMsg(ERROR_MESSAGE.INVALID_NUMBER_FORMAT, {
|
|
693
801
|
placeholders: ['invalidNumberFormat']
|
|
694
802
|
})
|
|
695
803
|
});
|
|
@@ -705,7 +813,7 @@ describe('NumberScheme', () => {
|
|
|
705
813
|
checkSchemeError({
|
|
706
814
|
data,
|
|
707
815
|
errorScheme,
|
|
708
|
-
message: createErrorMsg(
|
|
816
|
+
message: createErrorMsg(ERROR_MESSAGE.INVALID_NUMBER_FORMAT, {
|
|
709
817
|
placeholders: ['invalidNumberFormat']
|
|
710
818
|
})
|
|
711
819
|
});
|
|
@@ -730,8 +838,8 @@ describe('NumberScheme', () => {
|
|
|
730
838
|
throw new Error('spec failed');
|
|
731
839
|
}
|
|
732
840
|
|
|
733
|
-
expect(error.type).to.be.eql(
|
|
734
|
-
expect(error.message).to.be.eql(createErrorMsg(
|
|
841
|
+
expect(error.type).to.be.eql(ERROR_TYPE.FORMAT);
|
|
842
|
+
expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
|
|
735
843
|
placeholders: ['integer']
|
|
736
844
|
}));
|
|
737
845
|
});
|
|
@@ -765,8 +873,8 @@ describe('NumberScheme', () => {
|
|
|
765
873
|
throw new Error('spec failed');
|
|
766
874
|
}
|
|
767
875
|
|
|
768
|
-
expect(error.type).to.be.eql(
|
|
769
|
-
expect(error.message).to.be.eql(createErrorMsg(
|
|
876
|
+
expect(error.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
|
|
877
|
+
expect(error.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
|
|
770
878
|
placeholders: [JSON.stringify(formatArr)]
|
|
771
879
|
}));
|
|
772
880
|
});
|
|
@@ -868,8 +976,8 @@ describe('NumberScheme', () => {
|
|
|
868
976
|
throw new Error('spec failed');
|
|
869
977
|
}
|
|
870
978
|
|
|
871
|
-
expect(error1.type).to.be.eql(
|
|
872
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
979
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.FORMAT);
|
|
980
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
|
|
873
981
|
placeholders: ['index']
|
|
874
982
|
}));
|
|
875
983
|
|
|
@@ -887,8 +995,8 @@ describe('NumberScheme', () => {
|
|
|
887
995
|
throw new Error('spec failed');
|
|
888
996
|
}
|
|
889
997
|
|
|
890
|
-
expect(error2.type).to.be.eql(
|
|
891
|
-
expect(error2.message).to.be.eql(createErrorMsg(
|
|
998
|
+
expect(error2.type).to.be.eql(ERROR_TYPE.FORMAT);
|
|
999
|
+
expect(error2.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
|
|
892
1000
|
placeholders: ['index']
|
|
893
1001
|
}));
|
|
894
1002
|
|
|
@@ -906,8 +1014,8 @@ describe('NumberScheme', () => {
|
|
|
906
1014
|
throw new Error('spec failed');
|
|
907
1015
|
}
|
|
908
1016
|
|
|
909
|
-
expect(error3.type).to.be.eql(
|
|
910
|
-
expect(error3.message).to.be.eql(createErrorMsg(
|
|
1017
|
+
expect(error3.type).to.be.eql(ERROR_TYPE.FORMAT);
|
|
1018
|
+
expect(error3.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT, {
|
|
911
1019
|
placeholders: ['index']
|
|
912
1020
|
}));
|
|
913
1021
|
});
|
|
@@ -949,8 +1057,8 @@ describe('NumberScheme', () => {
|
|
|
949
1057
|
throw new Error('spec failed');
|
|
950
1058
|
}
|
|
951
1059
|
|
|
952
|
-
expect(error1.type).to.be.eql(
|
|
953
|
-
expect(error1.message).to.be.eql(createErrorMsg(
|
|
1060
|
+
expect(error1.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
|
|
1061
|
+
expect(error1.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
|
|
954
1062
|
placeholders: [JSON.stringify(formatArr)]
|
|
955
1063
|
}));
|
|
956
1064
|
|
|
@@ -968,8 +1076,8 @@ describe('NumberScheme', () => {
|
|
|
968
1076
|
throw new Error('spec failed');
|
|
969
1077
|
}
|
|
970
1078
|
|
|
971
|
-
expect(error2.type).to.be.eql(
|
|
972
|
-
expect(error2.message).to.be.eql(createErrorMsg(
|
|
1079
|
+
expect(error2.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
|
|
1080
|
+
expect(error2.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
|
|
973
1081
|
placeholders: [JSON.stringify(formatArr)]
|
|
974
1082
|
}));
|
|
975
1083
|
|
|
@@ -987,8 +1095,8 @@ describe('NumberScheme', () => {
|
|
|
987
1095
|
throw new Error('spec failed');
|
|
988
1096
|
}
|
|
989
1097
|
|
|
990
|
-
expect(error3.type).to.be.eql(
|
|
991
|
-
expect(error3.message).to.be.eql(createErrorMsg(
|
|
1098
|
+
expect(error3.type).to.be.eql(ERROR_TYPE.FORMAT_ONE_OF);
|
|
1099
|
+
expect(error3.message).to.be.eql(createErrorMsg(ERROR_MESSAGE.FORMAT_ONE_OF, {
|
|
992
1100
|
placeholders: [JSON.stringify(formatArr)]
|
|
993
1101
|
}));
|
|
994
1102
|
});
|