pg-mvc-service 2.0.73 → 2.0.75
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.
|
@@ -35,6 +35,7 @@ class RequestType extends ReqResType_1.default {
|
|
|
35
35
|
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
36
36
|
INVALID_MAP_NUMBER: '{property} must be a valid number for a map key. ({value})',
|
|
37
37
|
INVALID_MAP_STRING: '{property} must be a valid string for a map key. ({value})',
|
|
38
|
+
INVALID_MAP_BOOL: '{property} must be a valid boolean for a map key. ({value})',
|
|
38
39
|
};
|
|
39
40
|
this.ERROR_MESSAGE_JAPAN = {
|
|
40
41
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -54,6 +55,7 @@ class RequestType extends ReqResType_1.default {
|
|
|
54
55
|
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
55
56
|
INVALID_MAP_NUMBER: '{property} は有効な数値のマップキーでなければなりません。({value})',
|
|
56
57
|
INVALID_MAP_STRING: '{property} は有効な文字列のマップキーでなければなりません。({value})',
|
|
58
|
+
INVALID_MAP_BOOL: '{property} は有効なboolのマップキーでなければなりません。({value})',
|
|
57
59
|
};
|
|
58
60
|
this.ERROR_MESSAGE = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
59
61
|
this.paramProperties = [];
|
|
@@ -170,8 +172,19 @@ class RequestType extends ReqResType_1.default {
|
|
|
170
172
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
171
173
|
"MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
|
|
172
174
|
"MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
175
|
+
"MAP_03": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
176
|
+
"MAP_04": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
177
|
+
"MAP_05": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
173
178
|
"MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
174
179
|
"MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
180
|
+
"MAP_13": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
181
|
+
"MAP_14": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
182
|
+
"MAP_15": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
183
|
+
"MAP_31": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
184
|
+
"MAP_32": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
185
|
+
"MAP_33": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
186
|
+
"MAP_34": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
187
|
+
"MAP_35": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
175
188
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
176
189
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
177
190
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -289,14 +302,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
289
302
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
290
303
|
switch (this.properties[key].mapType) {
|
|
291
304
|
case 'number':
|
|
292
|
-
case 'number?':
|
|
293
305
|
if (this.isNumber(mapValue) === false) {
|
|
294
306
|
this.throwInputError("MAP_01", [key], value);
|
|
295
307
|
}
|
|
296
308
|
mapData[mapKey] = Number(mapValue);
|
|
297
309
|
break;
|
|
298
310
|
case 'string':
|
|
299
|
-
case 'string?':
|
|
300
311
|
switch (typeof mapValue) {
|
|
301
312
|
case 'number':
|
|
302
313
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -307,6 +318,27 @@ class RequestType extends ReqResType_1.default {
|
|
|
307
318
|
default:
|
|
308
319
|
this.throwInputError("MAP_02", [key], value);
|
|
309
320
|
}
|
|
321
|
+
break;
|
|
322
|
+
case 'bool':
|
|
323
|
+
switch (typeof mapValue) {
|
|
324
|
+
case 'boolean':
|
|
325
|
+
mapData[mapKey] = mapValue;
|
|
326
|
+
case 'number':
|
|
327
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
328
|
+
this.throwInputError("MAP_03", [key], mapValue);
|
|
329
|
+
}
|
|
330
|
+
mapData[mapKey] = mapValue === 1;
|
|
331
|
+
break;
|
|
332
|
+
case 'string':
|
|
333
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
334
|
+
this.throwInputError("MAP_04", [key], mapValue);
|
|
335
|
+
}
|
|
336
|
+
mapData[mapKey] = mapValue === 'true';
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
this.throwInputError("MAP_05", [key], mapValue);
|
|
340
|
+
}
|
|
341
|
+
break;
|
|
310
342
|
}
|
|
311
343
|
}
|
|
312
344
|
this.changeBody([key], mapData);
|
|
@@ -425,17 +457,16 @@ class RequestType extends ReqResType_1.default {
|
|
|
425
457
|
case 'map':
|
|
426
458
|
case 'map?':
|
|
427
459
|
const mapData = {};
|
|
460
|
+
console.log("amp-value", values[i]);
|
|
428
461
|
for (const [mapKey, mapValue] of Object.entries(values[i])) {
|
|
429
462
|
switch (property.item.mapType) {
|
|
430
463
|
case 'number':
|
|
431
|
-
case 'number?':
|
|
432
464
|
if (this.isNumber(mapValue) === false) {
|
|
433
|
-
this.throwInputError("
|
|
465
|
+
this.throwInputError("MAP_31", [...keys, i], values[i]);
|
|
434
466
|
}
|
|
435
467
|
mapData[mapKey] = Number(mapValue);
|
|
436
468
|
break;
|
|
437
469
|
case 'string':
|
|
438
|
-
case 'string?':
|
|
439
470
|
switch (typeof mapValue) {
|
|
440
471
|
case 'number':
|
|
441
472
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -444,8 +475,29 @@ class RequestType extends ReqResType_1.default {
|
|
|
444
475
|
mapData[mapKey] = mapValue;
|
|
445
476
|
break;
|
|
446
477
|
default:
|
|
447
|
-
this.throwInputError("
|
|
478
|
+
this.throwInputError("MAP_32", [...keys, i], values[i]);
|
|
479
|
+
}
|
|
480
|
+
break;
|
|
481
|
+
case 'bool':
|
|
482
|
+
switch (typeof mapValue) {
|
|
483
|
+
case 'boolean':
|
|
484
|
+
mapData[mapKey] = mapValue;
|
|
485
|
+
case 'number':
|
|
486
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
487
|
+
this.throwInputError("MAP_33", keys, mapValue);
|
|
488
|
+
}
|
|
489
|
+
mapData[mapKey] = mapValue === 1;
|
|
490
|
+
break;
|
|
491
|
+
case 'string':
|
|
492
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
493
|
+
this.throwInputError("MAP_34", keys, mapValue);
|
|
494
|
+
}
|
|
495
|
+
mapData[mapKey] = mapValue === 'true';
|
|
496
|
+
break;
|
|
497
|
+
default:
|
|
498
|
+
this.throwInputError("MAP_35", keys, mapValue);
|
|
448
499
|
}
|
|
500
|
+
break;
|
|
449
501
|
}
|
|
450
502
|
}
|
|
451
503
|
this.changeBody([...keys, i], mapData);
|
|
@@ -539,14 +591,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
539
591
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
540
592
|
switch (property.properties[key].mapType) {
|
|
541
593
|
case 'number':
|
|
542
|
-
case 'number?':
|
|
543
594
|
if (this.isNumber(mapValue) === false) {
|
|
544
595
|
this.throwInputError("MAP_11", [key], value);
|
|
545
596
|
}
|
|
546
597
|
mapData[mapKey] = Number(mapValue);
|
|
547
598
|
break;
|
|
548
599
|
case 'string':
|
|
549
|
-
case 'string?':
|
|
550
600
|
switch (typeof mapValue) {
|
|
551
601
|
case 'number':
|
|
552
602
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -557,6 +607,27 @@ class RequestType extends ReqResType_1.default {
|
|
|
557
607
|
default:
|
|
558
608
|
this.throwInputError("MAP_12", [key], value);
|
|
559
609
|
}
|
|
610
|
+
break;
|
|
611
|
+
case 'bool':
|
|
612
|
+
switch (typeof value) {
|
|
613
|
+
case 'boolean':
|
|
614
|
+
mapData[mapKey] = value;
|
|
615
|
+
case 'number':
|
|
616
|
+
if (value !== 0 && value !== 1) {
|
|
617
|
+
this.throwInputError("MAP_13", keys, value);
|
|
618
|
+
}
|
|
619
|
+
mapData[mapKey] = value === 1;
|
|
620
|
+
break;
|
|
621
|
+
case 'string':
|
|
622
|
+
if (value !== 'true' && value !== 'false') {
|
|
623
|
+
this.throwInputError("MAP_14", keys, value);
|
|
624
|
+
}
|
|
625
|
+
mapData[mapKey] = value === 'true';
|
|
626
|
+
break;
|
|
627
|
+
default:
|
|
628
|
+
this.throwInputError("MAP_15", keys, value);
|
|
629
|
+
}
|
|
630
|
+
break;
|
|
560
631
|
}
|
|
561
632
|
}
|
|
562
633
|
this.changeBody([...keys, key], mapData);
|
|
@@ -152,14 +152,12 @@ class ResponseType extends ReqResType_1.default {
|
|
|
152
152
|
for (const [key, value] of Object.entries(data)) {
|
|
153
153
|
switch (mapProperty.mapType) {
|
|
154
154
|
case 'number':
|
|
155
|
-
case 'number?':
|
|
156
155
|
if (this.isNumber(value) === false) {
|
|
157
156
|
continue;
|
|
158
157
|
}
|
|
159
158
|
mapData[key] = Number(value);
|
|
160
159
|
break;
|
|
161
160
|
case 'string':
|
|
162
|
-
case 'string?':
|
|
163
161
|
switch (typeof value) {
|
|
164
162
|
case 'number':
|
|
165
163
|
mapData[key] = value.toString();
|
|
@@ -170,6 +168,21 @@ class ResponseType extends ReqResType_1.default {
|
|
|
170
168
|
default:
|
|
171
169
|
continue;
|
|
172
170
|
}
|
|
171
|
+
case 'bool':
|
|
172
|
+
switch (typeof value) {
|
|
173
|
+
case 'boolean':
|
|
174
|
+
mapData[key] = value;
|
|
175
|
+
case 'number':
|
|
176
|
+
if (value === 0 || value === 1) {
|
|
177
|
+
mapData[key] = value === 1;
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
case 'string':
|
|
181
|
+
if (value !== 'true' && value !== 'false') {
|
|
182
|
+
mapData[key] = value === 'true';
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
return mapData;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export type ArrayType = {
|
|
|
21
21
|
export type MapType = {
|
|
22
22
|
type: 'map' | 'map?';
|
|
23
23
|
description?: string;
|
|
24
|
-
mapType: 'string' | 'number' | '
|
|
24
|
+
mapType: 'string' | 'number' | 'bool';
|
|
25
25
|
};
|
|
26
26
|
export type EnumType = {
|
|
27
27
|
type: 'enum' | 'enum?';
|
|
@@ -23,6 +23,7 @@ export interface ErrorMessageType {
|
|
|
23
23
|
INVALID_ENUM: string;
|
|
24
24
|
INVALID_MAP_NUMBER: string;
|
|
25
25
|
INVALID_MAP_STRING: string;
|
|
26
|
+
INVALID_MAP_BOOL: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export class RequestType extends ReqResType {
|
|
@@ -51,6 +52,7 @@ export class RequestType extends ReqResType {
|
|
|
51
52
|
INVALID_ENUM: '{property} must be in {enums}. ({value})',
|
|
52
53
|
INVALID_MAP_NUMBER: '{property} must be a valid number for a map key. ({value})',
|
|
53
54
|
INVALID_MAP_STRING: '{property} must be a valid string for a map key. ({value})',
|
|
55
|
+
INVALID_MAP_BOOL: '{property} must be a valid boolean for a map key. ({value})',
|
|
54
56
|
}
|
|
55
57
|
private readonly ERROR_MESSAGE_JAPAN: ErrorMessageType = {
|
|
56
58
|
REQUIRED: '{property}は必須項目です。',
|
|
@@ -70,6 +72,7 @@ export class RequestType extends ReqResType {
|
|
|
70
72
|
INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
|
|
71
73
|
INVALID_MAP_NUMBER: '{property} は有効な数値のマップキーでなければなりません。({value})',
|
|
72
74
|
INVALID_MAP_STRING: '{property} は有効な文字列のマップキーでなければなりません。({value})',
|
|
75
|
+
INVALID_MAP_BOOL: '{property} は有効なboolのマップキーでなければなりません。({value})',
|
|
73
76
|
}
|
|
74
77
|
protected readonly ERROR_MESSAGE: ErrorMessageType = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
|
|
75
78
|
|
|
@@ -144,7 +147,8 @@ export class RequestType extends ReqResType {
|
|
|
144
147
|
"TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
|
|
145
148
|
"REQUIRE_31" |
|
|
146
149
|
"ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
|
|
147
|
-
"MAP_01" | "MAP_02" | "MAP_11" | "MAP_12" |
|
|
150
|
+
"MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
|
|
151
|
+
"MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
|
|
148
152
|
"NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
|
|
149
153
|
"TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
|
|
150
154
|
, keys: Array<string | number>, value: any): never {
|
|
@@ -179,8 +183,19 @@ export class RequestType extends ReqResType {
|
|
|
179
183
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
180
184
|
"MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
|
|
181
185
|
"MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
186
|
+
"MAP_03": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
187
|
+
"MAP_04": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
188
|
+
"MAP_05": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
182
189
|
"MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
183
190
|
"MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
191
|
+
"MAP_13": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
192
|
+
"MAP_14": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
193
|
+
"MAP_15": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
194
|
+
"MAP_31": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
195
|
+
"MAP_32": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
196
|
+
"MAP_33": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
197
|
+
"MAP_34": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
198
|
+
"MAP_35": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
|
|
184
199
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
185
200
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
186
201
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -294,18 +309,16 @@ export class RequestType extends ReqResType {
|
|
|
294
309
|
case 'map':
|
|
295
310
|
case 'map?':
|
|
296
311
|
// tODO : ここは共通化したい
|
|
297
|
-
const mapData: {[key: string]: string | number} = {};
|
|
312
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
298
313
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
299
314
|
switch (this.properties[key].mapType) {
|
|
300
315
|
case 'number':
|
|
301
|
-
case 'number?':
|
|
302
316
|
if (this.isNumber(mapValue) === false) {
|
|
303
317
|
this.throwInputError("MAP_01", [key], value);
|
|
304
318
|
}
|
|
305
319
|
mapData[mapKey] = Number(mapValue);
|
|
306
320
|
break;
|
|
307
321
|
case 'string':
|
|
308
|
-
case 'string?':
|
|
309
322
|
switch (typeof mapValue) {
|
|
310
323
|
case 'number':
|
|
311
324
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -316,6 +329,27 @@ export class RequestType extends ReqResType {
|
|
|
316
329
|
default:
|
|
317
330
|
this.throwInputError("MAP_02", [key], value);
|
|
318
331
|
}
|
|
332
|
+
break;
|
|
333
|
+
case 'bool':
|
|
334
|
+
switch (typeof mapValue) {
|
|
335
|
+
case 'boolean':
|
|
336
|
+
mapData[mapKey] = mapValue;
|
|
337
|
+
case 'number':
|
|
338
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
339
|
+
this.throwInputError("MAP_03", [key], mapValue);
|
|
340
|
+
}
|
|
341
|
+
mapData[mapKey] = mapValue === 1;
|
|
342
|
+
break;
|
|
343
|
+
case 'string':
|
|
344
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
345
|
+
this.throwInputError("MAP_04", [key], mapValue);
|
|
346
|
+
}
|
|
347
|
+
mapData[mapKey] = mapValue === 'true';
|
|
348
|
+
break;
|
|
349
|
+
default:
|
|
350
|
+
this.throwInputError("MAP_05", [key], mapValue);
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
319
353
|
}
|
|
320
354
|
}
|
|
321
355
|
|
|
@@ -442,18 +476,17 @@ export class RequestType extends ReqResType {
|
|
|
442
476
|
break;
|
|
443
477
|
case 'map':
|
|
444
478
|
case 'map?':
|
|
445
|
-
const mapData: {[key: string]: string | number} = {};
|
|
479
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
480
|
+
console.log("amp-value", values[i]);
|
|
446
481
|
for (const [mapKey, mapValue] of Object.entries(values[i])) {
|
|
447
482
|
switch (property.item.mapType) {
|
|
448
483
|
case 'number':
|
|
449
|
-
case 'number?':
|
|
450
484
|
if (this.isNumber(mapValue) === false) {
|
|
451
|
-
this.throwInputError("
|
|
485
|
+
this.throwInputError("MAP_31", [...keys, i], values[i]);
|
|
452
486
|
}
|
|
453
487
|
mapData[mapKey] = Number(mapValue);
|
|
454
488
|
break;
|
|
455
489
|
case 'string':
|
|
456
|
-
case 'string?':
|
|
457
490
|
switch (typeof mapValue) {
|
|
458
491
|
case 'number':
|
|
459
492
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -462,8 +495,29 @@ export class RequestType extends ReqResType {
|
|
|
462
495
|
mapData[mapKey] = mapValue;
|
|
463
496
|
break;
|
|
464
497
|
default:
|
|
465
|
-
this.throwInputError("
|
|
498
|
+
this.throwInputError("MAP_32", [...keys, i], values[i]);
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
case 'bool':
|
|
502
|
+
switch (typeof mapValue) {
|
|
503
|
+
case 'boolean':
|
|
504
|
+
mapData[mapKey] = mapValue;
|
|
505
|
+
case 'number':
|
|
506
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
507
|
+
this.throwInputError("MAP_33", keys, mapValue);
|
|
508
|
+
}
|
|
509
|
+
mapData[mapKey] = mapValue === 1;
|
|
510
|
+
break;
|
|
511
|
+
case 'string':
|
|
512
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
513
|
+
this.throwInputError("MAP_34", keys, mapValue);
|
|
514
|
+
}
|
|
515
|
+
mapData[mapKey] = mapValue === 'true';
|
|
516
|
+
break;
|
|
517
|
+
default:
|
|
518
|
+
this.throwInputError("MAP_35", keys, mapValue);
|
|
466
519
|
}
|
|
520
|
+
break;
|
|
467
521
|
}
|
|
468
522
|
}
|
|
469
523
|
|
|
@@ -557,18 +611,16 @@ export class RequestType extends ReqResType {
|
|
|
557
611
|
break;
|
|
558
612
|
case 'map':
|
|
559
613
|
case 'map?':
|
|
560
|
-
const mapData: {[key: string]: string | number} = {};
|
|
614
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
561
615
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
562
616
|
switch (property.properties[key].mapType) {
|
|
563
617
|
case 'number':
|
|
564
|
-
case 'number?':
|
|
565
618
|
if (this.isNumber(mapValue) === false) {
|
|
566
619
|
this.throwInputError("MAP_11", [key], value);
|
|
567
620
|
}
|
|
568
621
|
mapData[mapKey] = Number(mapValue);
|
|
569
622
|
break;
|
|
570
623
|
case 'string':
|
|
571
|
-
case 'string?':
|
|
572
624
|
switch (typeof mapValue) {
|
|
573
625
|
case 'number':
|
|
574
626
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -579,6 +631,27 @@ export class RequestType extends ReqResType {
|
|
|
579
631
|
default:
|
|
580
632
|
this.throwInputError("MAP_12", [key], value);
|
|
581
633
|
}
|
|
634
|
+
break;
|
|
635
|
+
case 'bool':
|
|
636
|
+
switch (typeof value) {
|
|
637
|
+
case 'boolean':
|
|
638
|
+
mapData[mapKey] = value;
|
|
639
|
+
case 'number':
|
|
640
|
+
if (value !== 0 && value !== 1) {
|
|
641
|
+
this.throwInputError("MAP_13", keys, value);
|
|
642
|
+
}
|
|
643
|
+
mapData[mapKey] = value === 1;
|
|
644
|
+
break;
|
|
645
|
+
case 'string':
|
|
646
|
+
if (value !== 'true' && value !== 'false') {
|
|
647
|
+
this.throwInputError("MAP_14", keys, value);
|
|
648
|
+
}
|
|
649
|
+
mapData[mapKey] = value === 'true';
|
|
650
|
+
break;
|
|
651
|
+
default:
|
|
652
|
+
this.throwInputError("MAP_15", keys, value);
|
|
653
|
+
}
|
|
654
|
+
break;
|
|
582
655
|
}
|
|
583
656
|
}
|
|
584
657
|
|
|
@@ -162,18 +162,16 @@ export class ResponseType extends ReqResType {
|
|
|
162
162
|
throw new Error(`getMapメソッドでMap型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
const mapData: {[key: string]: string | number} = {};
|
|
165
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
166
166
|
for (const [key, value] of Object.entries(data)) {
|
|
167
167
|
switch (mapProperty.mapType) {
|
|
168
168
|
case 'number':
|
|
169
|
-
case 'number?':
|
|
170
169
|
if (this.isNumber(value) === false) {
|
|
171
170
|
continue;
|
|
172
171
|
}
|
|
173
172
|
mapData[key] = Number(value);
|
|
174
173
|
break;
|
|
175
174
|
case 'string':
|
|
176
|
-
case 'string?':
|
|
177
175
|
switch (typeof value) {
|
|
178
176
|
case 'number':
|
|
179
177
|
mapData[key] = value.toString();
|
|
@@ -184,6 +182,21 @@ export class ResponseType extends ReqResType {
|
|
|
184
182
|
default:
|
|
185
183
|
continue;
|
|
186
184
|
}
|
|
185
|
+
case 'bool':
|
|
186
|
+
switch (typeof value) {
|
|
187
|
+
case 'boolean':
|
|
188
|
+
mapData[key] = value;
|
|
189
|
+
case 'number':
|
|
190
|
+
if (value === 0 || value === 1) {
|
|
191
|
+
mapData[key] = value === 1;
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
case 'string':
|
|
195
|
+
if (value !== 'true' && value !== 'false') {
|
|
196
|
+
mapData[key] = value === 'true';
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
187
200
|
}
|
|
188
201
|
}
|
|
189
202
|
|