pg-mvc-service 2.0.72 → 2.0.74
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,14 @@ 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_STRING,
|
|
176
|
+
"MAP_04": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
177
|
+
"MAP_05": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
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_STRING,
|
|
181
|
+
"MAP_14": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
182
|
+
"MAP_15": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
175
183
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
176
184
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
177
185
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -289,14 +297,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
289
297
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
290
298
|
switch (this.properties[key].mapType) {
|
|
291
299
|
case 'number':
|
|
292
|
-
case 'number?':
|
|
293
300
|
if (this.isNumber(mapValue) === false) {
|
|
294
301
|
this.throwInputError("MAP_01", [key], value);
|
|
295
302
|
}
|
|
296
303
|
mapData[mapKey] = Number(mapValue);
|
|
297
304
|
break;
|
|
298
305
|
case 'string':
|
|
299
|
-
case 'string?':
|
|
300
306
|
switch (typeof mapValue) {
|
|
301
307
|
case 'number':
|
|
302
308
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -307,6 +313,25 @@ class RequestType extends ReqResType_1.default {
|
|
|
307
313
|
default:
|
|
308
314
|
this.throwInputError("MAP_02", [key], value);
|
|
309
315
|
}
|
|
316
|
+
case 'bool':
|
|
317
|
+
switch (typeof mapValue) {
|
|
318
|
+
case 'boolean':
|
|
319
|
+
mapData[mapKey] = mapValue;
|
|
320
|
+
case 'number':
|
|
321
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
322
|
+
this.throwInputError("MAP_03", [key], mapValue);
|
|
323
|
+
}
|
|
324
|
+
mapData[mapKey] = mapValue === 1;
|
|
325
|
+
break;
|
|
326
|
+
case 'string':
|
|
327
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
328
|
+
this.throwInputError("MAP_04", [key], mapValue);
|
|
329
|
+
}
|
|
330
|
+
mapData[mapKey] = mapValue === 'true';
|
|
331
|
+
break;
|
|
332
|
+
default:
|
|
333
|
+
this.throwInputError("MAP_05", [key], mapValue);
|
|
334
|
+
}
|
|
310
335
|
}
|
|
311
336
|
}
|
|
312
337
|
this.changeBody([key], mapData);
|
|
@@ -428,14 +453,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
428
453
|
for (const [mapKey, mapValue] of Object.entries(values[i])) {
|
|
429
454
|
switch (property.item.mapType) {
|
|
430
455
|
case 'number':
|
|
431
|
-
case 'number?':
|
|
432
456
|
if (this.isNumber(mapValue) === false) {
|
|
433
457
|
this.throwInputError("MAP_11", [...keys, i], values[i]);
|
|
434
458
|
}
|
|
435
459
|
mapData[mapKey] = Number(mapValue);
|
|
436
460
|
break;
|
|
437
461
|
case 'string':
|
|
438
|
-
case 'string?':
|
|
439
462
|
switch (typeof mapValue) {
|
|
440
463
|
case 'number':
|
|
441
464
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -446,6 +469,25 @@ class RequestType extends ReqResType_1.default {
|
|
|
446
469
|
default:
|
|
447
470
|
this.throwInputError("MAP_12", [...keys, i], values[i]);
|
|
448
471
|
}
|
|
472
|
+
case 'bool':
|
|
473
|
+
switch (typeof mapValue) {
|
|
474
|
+
case 'boolean':
|
|
475
|
+
mapData[mapKey] = mapValue;
|
|
476
|
+
case 'number':
|
|
477
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
478
|
+
this.throwInputError("MAP_13", keys, mapValue);
|
|
479
|
+
}
|
|
480
|
+
mapData[mapKey] = mapValue === 1;
|
|
481
|
+
break;
|
|
482
|
+
case 'string':
|
|
483
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
484
|
+
this.throwInputError("MAP_14", keys, mapValue);
|
|
485
|
+
}
|
|
486
|
+
mapData[mapKey] = mapValue === 'true';
|
|
487
|
+
break;
|
|
488
|
+
default:
|
|
489
|
+
this.throwInputError("MAP_15", keys, mapValue);
|
|
490
|
+
}
|
|
449
491
|
}
|
|
450
492
|
}
|
|
451
493
|
this.changeBody([...keys, i], mapData);
|
|
@@ -539,14 +581,12 @@ class RequestType extends ReqResType_1.default {
|
|
|
539
581
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
540
582
|
switch (property.properties[key].mapType) {
|
|
541
583
|
case 'number':
|
|
542
|
-
case 'number?':
|
|
543
584
|
if (this.isNumber(mapValue) === false) {
|
|
544
585
|
this.throwInputError("MAP_11", [key], value);
|
|
545
586
|
}
|
|
546
587
|
mapData[mapKey] = Number(mapValue);
|
|
547
588
|
break;
|
|
548
589
|
case 'string':
|
|
549
|
-
case 'string?':
|
|
550
590
|
switch (typeof mapValue) {
|
|
551
591
|
case 'number':
|
|
552
592
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -557,6 +597,25 @@ class RequestType extends ReqResType_1.default {
|
|
|
557
597
|
default:
|
|
558
598
|
this.throwInputError("MAP_12", [key], value);
|
|
559
599
|
}
|
|
600
|
+
case 'bool':
|
|
601
|
+
switch (typeof value) {
|
|
602
|
+
case 'boolean':
|
|
603
|
+
mapData[mapKey] = value;
|
|
604
|
+
case 'number':
|
|
605
|
+
if (value !== 0 && value !== 1) {
|
|
606
|
+
this.throwInputError("MAP_13", keys, value);
|
|
607
|
+
}
|
|
608
|
+
mapData[mapKey] = value === 1;
|
|
609
|
+
break;
|
|
610
|
+
case 'string':
|
|
611
|
+
if (value !== 'true' && value !== 'false') {
|
|
612
|
+
this.throwInputError("MAP_14", keys, value);
|
|
613
|
+
}
|
|
614
|
+
mapData[mapKey] = value === 'true';
|
|
615
|
+
break;
|
|
616
|
+
default:
|
|
617
|
+
this.throwInputError("MAP_15", keys, value);
|
|
618
|
+
}
|
|
560
619
|
}
|
|
561
620
|
}
|
|
562
621
|
this.changeBody([...keys, key], mapData);
|
|
@@ -141,7 +141,6 @@ class ResponseType extends ReqResType_1.default {
|
|
|
141
141
|
*/
|
|
142
142
|
getMap(keys) {
|
|
143
143
|
const data = this.getData(keys);
|
|
144
|
-
console.log("getMap: data : ", data);
|
|
145
144
|
if (data === undefined) {
|
|
146
145
|
return undefined;
|
|
147
146
|
}
|
|
@@ -149,21 +148,16 @@ class ResponseType extends ReqResType_1.default {
|
|
|
149
148
|
if (mapProperty.type !== 'map' && mapProperty.type !== 'map?') {
|
|
150
149
|
throw new Error(`getMapメソッドでMap型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
|
|
151
150
|
}
|
|
152
|
-
console.log("getMap: keys : ", keys);
|
|
153
151
|
const mapData = {};
|
|
154
|
-
for (const [key, value] of data) {
|
|
155
|
-
console.log("getMap: key : ", key);
|
|
156
|
-
console.log("getMap: value : ", value);
|
|
152
|
+
for (const [key, value] of Object.entries(data)) {
|
|
157
153
|
switch (mapProperty.mapType) {
|
|
158
154
|
case 'number':
|
|
159
|
-
case 'number?':
|
|
160
155
|
if (this.isNumber(value) === false) {
|
|
161
156
|
continue;
|
|
162
157
|
}
|
|
163
158
|
mapData[key] = Number(value);
|
|
164
159
|
break;
|
|
165
160
|
case 'string':
|
|
166
|
-
case 'string?':
|
|
167
161
|
switch (typeof value) {
|
|
168
162
|
case 'number':
|
|
169
163
|
mapData[key] = value.toString();
|
|
@@ -174,6 +168,21 @@ class ResponseType extends ReqResType_1.default {
|
|
|
174
168
|
default:
|
|
175
169
|
continue;
|
|
176
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
|
+
}
|
|
177
186
|
}
|
|
178
187
|
}
|
|
179
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,7 @@ 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" |
|
|
148
151
|
"NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
|
|
149
152
|
"TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
|
|
150
153
|
, keys: Array<string | number>, value: any): never {
|
|
@@ -179,8 +182,14 @@ export class RequestType extends ReqResType {
|
|
|
179
182
|
"ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
|
|
180
183
|
"MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
|
|
181
184
|
"MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
185
|
+
"MAP_03": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
186
|
+
"MAP_04": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
187
|
+
"MAP_05": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
182
188
|
"MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
|
|
183
189
|
"MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
190
|
+
"MAP_13": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
191
|
+
"MAP_14": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
192
|
+
"MAP_15": this.ERROR_MESSAGE.INVALID_MAP_STRING,
|
|
184
193
|
"NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
|
|
185
194
|
"BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
186
195
|
"BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
|
|
@@ -294,18 +303,16 @@ export class RequestType extends ReqResType {
|
|
|
294
303
|
case 'map':
|
|
295
304
|
case 'map?':
|
|
296
305
|
// tODO : ここは共通化したい
|
|
297
|
-
const mapData: {[key: string]: string | number} = {};
|
|
306
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
298
307
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
299
308
|
switch (this.properties[key].mapType) {
|
|
300
309
|
case 'number':
|
|
301
|
-
case 'number?':
|
|
302
310
|
if (this.isNumber(mapValue) === false) {
|
|
303
311
|
this.throwInputError("MAP_01", [key], value);
|
|
304
312
|
}
|
|
305
313
|
mapData[mapKey] = Number(mapValue);
|
|
306
314
|
break;
|
|
307
315
|
case 'string':
|
|
308
|
-
case 'string?':
|
|
309
316
|
switch (typeof mapValue) {
|
|
310
317
|
case 'number':
|
|
311
318
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -316,6 +323,25 @@ export class RequestType extends ReqResType {
|
|
|
316
323
|
default:
|
|
317
324
|
this.throwInputError("MAP_02", [key], value);
|
|
318
325
|
}
|
|
326
|
+
case 'bool':
|
|
327
|
+
switch (typeof mapValue) {
|
|
328
|
+
case 'boolean':
|
|
329
|
+
mapData[mapKey] = mapValue;
|
|
330
|
+
case 'number':
|
|
331
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
332
|
+
this.throwInputError("MAP_03", [key], mapValue);
|
|
333
|
+
}
|
|
334
|
+
mapData[mapKey] = mapValue === 1;
|
|
335
|
+
break;
|
|
336
|
+
case 'string':
|
|
337
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
338
|
+
this.throwInputError("MAP_04", [key], mapValue);
|
|
339
|
+
}
|
|
340
|
+
mapData[mapKey] = mapValue === 'true';
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
this.throwInputError("MAP_05", [key], mapValue);
|
|
344
|
+
}
|
|
319
345
|
}
|
|
320
346
|
}
|
|
321
347
|
|
|
@@ -442,18 +468,16 @@ export class RequestType extends ReqResType {
|
|
|
442
468
|
break;
|
|
443
469
|
case 'map':
|
|
444
470
|
case 'map?':
|
|
445
|
-
const mapData: {[key: string]: string | number} = {};
|
|
471
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
446
472
|
for (const [mapKey, mapValue] of Object.entries(values[i])) {
|
|
447
473
|
switch (property.item.mapType) {
|
|
448
474
|
case 'number':
|
|
449
|
-
case 'number?':
|
|
450
475
|
if (this.isNumber(mapValue) === false) {
|
|
451
476
|
this.throwInputError("MAP_11", [...keys, i], values[i]);
|
|
452
477
|
}
|
|
453
478
|
mapData[mapKey] = Number(mapValue);
|
|
454
479
|
break;
|
|
455
480
|
case 'string':
|
|
456
|
-
case 'string?':
|
|
457
481
|
switch (typeof mapValue) {
|
|
458
482
|
case 'number':
|
|
459
483
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -464,6 +488,25 @@ export class RequestType extends ReqResType {
|
|
|
464
488
|
default:
|
|
465
489
|
this.throwInputError("MAP_12", [...keys, i], values[i]);
|
|
466
490
|
}
|
|
491
|
+
case 'bool':
|
|
492
|
+
switch (typeof mapValue) {
|
|
493
|
+
case 'boolean':
|
|
494
|
+
mapData[mapKey] = mapValue;
|
|
495
|
+
case 'number':
|
|
496
|
+
if (mapValue !== 0 && mapValue !== 1) {
|
|
497
|
+
this.throwInputError("MAP_13", keys, mapValue);
|
|
498
|
+
}
|
|
499
|
+
mapData[mapKey] = mapValue === 1;
|
|
500
|
+
break;
|
|
501
|
+
case 'string':
|
|
502
|
+
if (mapValue !== 'true' && mapValue !== 'false') {
|
|
503
|
+
this.throwInputError("MAP_14", keys, mapValue);
|
|
504
|
+
}
|
|
505
|
+
mapData[mapKey] = mapValue === 'true';
|
|
506
|
+
break;
|
|
507
|
+
default:
|
|
508
|
+
this.throwInputError("MAP_15", keys, mapValue);
|
|
509
|
+
}
|
|
467
510
|
}
|
|
468
511
|
}
|
|
469
512
|
|
|
@@ -557,18 +600,16 @@ export class RequestType extends ReqResType {
|
|
|
557
600
|
break;
|
|
558
601
|
case 'map':
|
|
559
602
|
case 'map?':
|
|
560
|
-
const mapData: {[key: string]: string | number} = {};
|
|
603
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
561
604
|
for (const [mapKey, mapValue] of Object.entries(value)) {
|
|
562
605
|
switch (property.properties[key].mapType) {
|
|
563
606
|
case 'number':
|
|
564
|
-
case 'number?':
|
|
565
607
|
if (this.isNumber(mapValue) === false) {
|
|
566
608
|
this.throwInputError("MAP_11", [key], value);
|
|
567
609
|
}
|
|
568
610
|
mapData[mapKey] = Number(mapValue);
|
|
569
611
|
break;
|
|
570
612
|
case 'string':
|
|
571
|
-
case 'string?':
|
|
572
613
|
switch (typeof mapValue) {
|
|
573
614
|
case 'number':
|
|
574
615
|
mapData[mapKey] = mapValue.toString();
|
|
@@ -579,6 +620,25 @@ export class RequestType extends ReqResType {
|
|
|
579
620
|
default:
|
|
580
621
|
this.throwInputError("MAP_12", [key], value);
|
|
581
622
|
}
|
|
623
|
+
case 'bool':
|
|
624
|
+
switch (typeof value) {
|
|
625
|
+
case 'boolean':
|
|
626
|
+
mapData[mapKey] = value;
|
|
627
|
+
case 'number':
|
|
628
|
+
if (value !== 0 && value !== 1) {
|
|
629
|
+
this.throwInputError("MAP_13", keys, value);
|
|
630
|
+
}
|
|
631
|
+
mapData[mapKey] = value === 1;
|
|
632
|
+
break;
|
|
633
|
+
case 'string':
|
|
634
|
+
if (value !== 'true' && value !== 'false') {
|
|
635
|
+
this.throwInputError("MAP_14", keys, value);
|
|
636
|
+
}
|
|
637
|
+
mapData[mapKey] = value === 'true';
|
|
638
|
+
break;
|
|
639
|
+
default:
|
|
640
|
+
this.throwInputError("MAP_15", keys, value);
|
|
641
|
+
}
|
|
582
642
|
}
|
|
583
643
|
}
|
|
584
644
|
|
|
@@ -153,7 +153,6 @@ export class ResponseType extends ReqResType {
|
|
|
153
153
|
private getMap(keys: Array<string | number>) {
|
|
154
154
|
|
|
155
155
|
const data = this.getData(keys);
|
|
156
|
-
console.log("getMap: data : ", data);
|
|
157
156
|
if (data === undefined) {
|
|
158
157
|
return undefined;
|
|
159
158
|
}
|
|
@@ -163,21 +162,16 @@ export class ResponseType extends ReqResType {
|
|
|
163
162
|
throw new Error(`getMapメソッドでMap型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
for (const [key, value] of data) {
|
|
169
|
-
console.log("getMap: key : ", key);
|
|
170
|
-
console.log("getMap: value : ", value);
|
|
165
|
+
const mapData: {[key: string]: string | number | boolean} = {};
|
|
166
|
+
for (const [key, value] of Object.entries(data)) {
|
|
171
167
|
switch (mapProperty.mapType) {
|
|
172
168
|
case 'number':
|
|
173
|
-
case 'number?':
|
|
174
169
|
if (this.isNumber(value) === false) {
|
|
175
170
|
continue;
|
|
176
171
|
}
|
|
177
172
|
mapData[key] = Number(value);
|
|
178
173
|
break;
|
|
179
174
|
case 'string':
|
|
180
|
-
case 'string?':
|
|
181
175
|
switch (typeof value) {
|
|
182
176
|
case 'number':
|
|
183
177
|
mapData[key] = value.toString();
|
|
@@ -188,6 +182,21 @@ export class ResponseType extends ReqResType {
|
|
|
188
182
|
default:
|
|
189
183
|
continue;
|
|
190
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
|
+
}
|
|
191
200
|
}
|
|
192
201
|
}
|
|
193
202
|
|