pg-mvc-service 2.0.77 → 2.0.79

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.
@@ -66,13 +66,6 @@ class ReqResType {
66
66
  }
67
67
  property = property.properties[key];
68
68
  continue;
69
- // case 'dictionary':
70
- // case 'dictionary?':
71
- // if (typeof key !== 'string') {
72
- // throw new Error(`getPropertyでnumber型のINPUTで、arrayの場合はエラー\nキー一覧:${keys.join(',')} エラーキー:${key}`);
73
- // }
74
- // property = property.properties[key];
75
- // continue;
76
69
  default:
77
70
  throw new Error(`getPropertyでarray,object以外のtypeを読み込もうとしている。\nキー一覧:${keys.join(',')} エラーキー:${key}`);
78
71
  // property = property[key];
@@ -166,6 +166,9 @@ class RequestType extends ReqResType_1.default {
166
166
  "HTTPS_21": this.ERROR_MESSAGE.INVALID_HTTPS,
167
167
  "BASE64_21": this.ERROR_MESSAGE.INVALID_BASE64,
168
168
  "REQUIRE_31": this.ERROR_MESSAGE.REQUIRED,
169
+ "NUMBER_31": this.ERROR_MESSAGE.INVALID_NUMBER,
170
+ "STRING_31": this.ERROR_MESSAGE.INVALID_STRING,
171
+ "ENUM_32": this.ERROR_MESSAGE.INVALID_ENUM,
169
172
  "NUMBER_41": this.ERROR_MESSAGE.INVALID_NUMBER,
170
173
  "STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
171
174
  "ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
@@ -201,7 +204,7 @@ class RequestType extends ReqResType_1.default {
201
204
  "BASE64_91": this.ERROR_MESSAGE.INVALID_BASE64,
202
205
  };
203
206
  let errorMessage = list[code];
204
- if (code === "ENUM_41" || code === "ENUM_42") {
207
+ if (code === "ENUM_32" || code === "ENUM_41" || code === "ENUM_42") {
205
208
  const property = this.getProperty(keys);
206
209
  errorMessage = errorMessage.replace('{enums}', Object.keys((_a = property.enums) !== null && _a !== void 0 ? _a : '').join(','));
207
210
  }
@@ -451,8 +454,34 @@ class RequestType extends ReqResType_1.default {
451
454
  break;
452
455
  case 'enum':
453
456
  case 'enum?':
457
+ const toEnumValue = [];
454
458
  for (const value of values) {
455
- this.setEnum([...keys, i], value);
459
+ switch (property.item.enumType) {
460
+ case 'number':
461
+ case 'number?':
462
+ if (this.isNumber(value) === false) {
463
+ this.throwInputError("NUMBER_31", keys, value);
464
+ }
465
+ toEnumValue.push(Number(value));
466
+ break;
467
+ case 'string':
468
+ case 'string?':
469
+ switch (typeof value) {
470
+ case 'number':
471
+ toEnumValue.push(value.toString());
472
+ break;
473
+ case 'string':
474
+ toEnumValue.push(value);
475
+ break;
476
+ default:
477
+ this.throwInputError("STRING_31", keys, value);
478
+ }
479
+ break;
480
+ }
481
+ if (Object.keys(property.item.enums).includes(value.toString()) === false) {
482
+ this.throwInputError("ENUM_32", keys, value);
483
+ }
484
+ this.setEnum([...keys, i], toEnumValue);
456
485
  }
457
486
  break;
458
487
  case 'map':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.77",
3
+ "version": "2.0.79",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -103,13 +103,6 @@ export default class ReqResType {
103
103
  }
104
104
  property = property.properties[key];
105
105
  continue;
106
- // case 'dictionary':
107
- // case 'dictionary?':
108
- // if (typeof key !== 'string') {
109
- // throw new Error(`getPropertyでnumber型のINPUTで、arrayの場合はエラー\nキー一覧:${keys.join(',')} エラーキー:${key}`);
110
- // }
111
- // property = property.properties[key];
112
- // continue;
113
106
  default:
114
107
  throw new Error(`getPropertyでarray,object以外のtypeを読み込もうとしている。\nキー一覧:${keys.join(',')} エラーキー:${key}`);
115
108
  // property = property[key];
@@ -146,7 +146,7 @@ export class RequestType extends ReqResType {
146
146
  "NUMBER_21" | "BOOL_21" | "BOOL_22" | "BOOL_23" | "STRING_21" | "UUID_21" | "MAIL_21" | "DATE_21" | "DATE_22" |
147
147
  "TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
148
148
  "REQUIRE_31" |
149
- "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
149
+ "ENUM_32" | "NUMBER_31" | "STRING_31" | "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
150
150
  "MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
151
151
  "MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
152
152
  "NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
@@ -177,6 +177,9 @@ export class RequestType extends ReqResType {
177
177
  "HTTPS_21": this.ERROR_MESSAGE.INVALID_HTTPS,
178
178
  "BASE64_21": this.ERROR_MESSAGE.INVALID_BASE64,
179
179
  "REQUIRE_31": this.ERROR_MESSAGE.REQUIRED,
180
+ "NUMBER_31": this.ERROR_MESSAGE.INVALID_NUMBER,
181
+ "STRING_31": this.ERROR_MESSAGE.INVALID_STRING,
182
+ "ENUM_32": this.ERROR_MESSAGE.INVALID_ENUM,
180
183
  "NUMBER_41": this.ERROR_MESSAGE.INVALID_NUMBER,
181
184
  "STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
182
185
  "ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
@@ -213,7 +216,7 @@ export class RequestType extends ReqResType {
213
216
  }
214
217
 
215
218
  let errorMessage = list[code];
216
- if (code === "ENUM_41" || code === "ENUM_42") {
219
+ if (code === "ENUM_32" || code === "ENUM_41" || code === "ENUM_42") {
217
220
  const property = this.getProperty(keys) as EnumType;
218
221
  errorMessage = errorMessage.replace('{enums}', Object.keys(property.enums ?? '').join(','));
219
222
  }
@@ -471,8 +474,35 @@ export class RequestType extends ReqResType {
471
474
  break;
472
475
  case 'enum':
473
476
  case 'enum?':
474
- for (const value of values) {
475
- this.setEnum([...keys, i], value);
477
+ const toEnumValue = [];
478
+ for (const value of values) {
479
+ switch (property.item.enumType) {
480
+ case 'number':
481
+ case 'number?':
482
+ if (this.isNumber(value) === false) {
483
+ this.throwInputError("NUMBER_31", keys, value);
484
+ }
485
+ toEnumValue.push(Number(value));
486
+ break;
487
+ case 'string':
488
+ case 'string?':
489
+ switch (typeof value) {
490
+ case 'number':
491
+ toEnumValue.push(value.toString());
492
+ break;
493
+ case 'string':
494
+ toEnumValue.push(value);
495
+ break;
496
+ default:
497
+ this.throwInputError("STRING_31", keys, value);
498
+ }
499
+ break;
500
+ }
501
+
502
+ if (Object.keys(property.item.enums).includes(value.toString()) === false) {
503
+ this.throwInputError("ENUM_32", keys, value);
504
+ }
505
+ this.setEnum([...keys, i], toEnumValue);
476
506
  }
477
507
  break;
478
508
  case 'map':