@yamato-daiwa/es-extensions 1.4.1 → 1.4.4
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/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessor.js +85 -87
- package/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessorLocalization__English.js +54 -55
- package/Distributable/cjs/Strings/stringifyAndFormatArbitraryValue.js +1 -1
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.d.ts +7 -7
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.js +85 -87
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessorLocalization__English.js +54 -55
- package/Distributable/esm/Strings/stringifyAndFormatArbitraryValue.js +1 -1
- package/README.md +46 -46
- package/package.json +1 -1
|
@@ -16,7 +16,6 @@ const isDecimalFractionOfAnySign_1 = require("../TypeGuards/Numbers/isDecimalFra
|
|
|
16
16
|
const isString_1 = require("../TypeGuards/Strings/isString");
|
|
17
17
|
const isBoolean_1 = require("../TypeGuards/isBoolean");
|
|
18
18
|
const isNonEmptyArray_1 = require("../TypeGuards/Arrays/isNonEmptyArray");
|
|
19
|
-
const substituteWhenUndefined_1 = require("../DefaultValueSubstituters/substituteWhenUndefined");
|
|
20
19
|
const stringifyAndFormatArbitraryValue_1 = require("../Strings/stringifyAndFormatArbitraryValue");
|
|
21
20
|
const Logger_1 = require("../Logging/Logger");
|
|
22
21
|
const InvalidParameterValueError_1 = require("../Logging/Errors/InvalidParameterValue/InvalidParameterValueError");
|
|
@@ -33,7 +32,8 @@ class RawObjectDataProcessor {
|
|
|
33
32
|
this.validationErrorsMessagesBuilder = parametersObject.validationErrorsMessagesBuilder;
|
|
34
33
|
}
|
|
35
34
|
static process(rawData, validDataSpecification, options = {}) {
|
|
36
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
const localization = (_a = options.localization) !== null && _a !== void 0 ? _a : RawObjectDataProcessor.defaultLocalization;
|
|
37
37
|
const validationErrorsMessagesBuilder = new RawObjectDataProcessor.ValidationErrorsMessagesBuilder(localization);
|
|
38
38
|
if ((0, isNull_1.default)(rawData)) {
|
|
39
39
|
return {
|
|
@@ -59,10 +59,9 @@ class RawObjectDataProcessor {
|
|
|
59
59
|
rawDataProcessingResult = dataHoldingSelfInstance.processFixedKeyAndValuePairsNonNullObjectTypeValue({
|
|
60
60
|
targetValue__expectedToBeObject: rawData,
|
|
61
61
|
targetObjectTypeValueSpecification: {
|
|
62
|
-
...
|
|
63
|
-
...
|
|
64
|
-
}
|
|
65
|
-
parentObject: rawData
|
|
62
|
+
...{ type: RawObjectDataProcessor.ValuesTypesIDs.fixedKeyAndValuePairsObject },
|
|
63
|
+
...validDataSpecification
|
|
64
|
+
}
|
|
66
65
|
});
|
|
67
66
|
break;
|
|
68
67
|
}
|
|
@@ -72,8 +71,7 @@ class RawObjectDataProcessor {
|
|
|
72
71
|
targetIndexedArrayTypeValueSpecification: {
|
|
73
72
|
...validDataSpecification,
|
|
74
73
|
...{ type: RawObjectDataProcessor.ValuesTypesIDs.indexedArrayOfUniformElements }
|
|
75
|
-
}
|
|
76
|
-
parentObject: rawData
|
|
74
|
+
}
|
|
77
75
|
});
|
|
78
76
|
break;
|
|
79
77
|
}
|
|
@@ -83,8 +81,7 @@ class RawObjectDataProcessor {
|
|
|
83
81
|
targetAssociativeArrayTypeValueSpecification: {
|
|
84
82
|
...validDataSpecification,
|
|
85
83
|
...{ type: RawObjectDataProcessor.ValuesTypesIDs.associativeArrayOfUniformTypeValues }
|
|
86
|
-
}
|
|
87
|
-
parentObject: rawData
|
|
84
|
+
}
|
|
88
85
|
});
|
|
89
86
|
}
|
|
90
87
|
}
|
|
@@ -108,7 +105,7 @@ class RawObjectDataProcessor {
|
|
|
108
105
|
}
|
|
109
106
|
static formatValidationErrorsList(messages, localization = RawObjectDataProcessor.defaultLocalization) {
|
|
110
107
|
return messages.reduce((accumulatingValue, message, index) => `${accumulatingValue}\n\n` +
|
|
111
|
-
`${localization.
|
|
108
|
+
`${localization.buildErrorMessagesListItemHeading(index + 1)}\n` +
|
|
112
109
|
`${message}`, "");
|
|
113
110
|
}
|
|
114
111
|
static setDefaultLocalization(newLocalization) {
|
|
@@ -145,7 +142,7 @@ class RawObjectDataProcessor {
|
|
|
145
142
|
Logger_1.default.throwErrorAndLog({
|
|
146
143
|
errorInstance: new InvalidParameterValueError_1.default({ parameterName: "valueType" }),
|
|
147
144
|
title: InvalidParameterValueError_1.default.DEFAULT_TITLE,
|
|
148
|
-
occurrenceLocation: "RawObjectDataProcessor.processSingleNeitherUndefinedNorNullValue(
|
|
145
|
+
occurrenceLocation: "RawObjectDataProcessor.processSingleNeitherUndefinedNorNullValue(valueType)"
|
|
149
146
|
});
|
|
150
147
|
}
|
|
151
148
|
processFixedKeyAndValuePairsNonNullObjectTypeValue({ targetValue__expectedToBeObject, targetObjectTypeValueSpecification, parentObject, targetPropertyStringifiedValueBeforeFirstPreValidationModification }) {
|
|
@@ -162,7 +159,7 @@ class RawObjectDataProcessor {
|
|
|
162
159
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.existingObjectManipulation ?
|
|
163
160
|
targetValue__expectedToBeObject : {};
|
|
164
161
|
const currentObjectDepthLevel__countFromZero = this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging.length;
|
|
165
|
-
let
|
|
162
|
+
let areOneOnMorePropertiesInvalid = false;
|
|
166
163
|
for (const [childPropertyName, childPropertySpecification] of Object.entries(targetObjectTypeValueSpecification.properties)) {
|
|
167
164
|
this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging[currentObjectDepthLevel__countFromZero] = childPropertyName;
|
|
168
165
|
let childPropertyFinalName;
|
|
@@ -197,7 +194,7 @@ class RawObjectDataProcessor {
|
|
|
197
194
|
}
|
|
198
195
|
if ((0, isUndefined_1.default)(childPropertyValue)) {
|
|
199
196
|
if (childPropertySpecification.required === true) {
|
|
200
|
-
|
|
197
|
+
areOneOnMorePropertiesInvalid = true;
|
|
201
198
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildRequiredPropertyIsMissingErrorMessage({
|
|
202
199
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
203
200
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -209,7 +206,7 @@ class RawObjectDataProcessor {
|
|
|
209
206
|
}
|
|
210
207
|
if ((0, isNotUndefined_1.default)(childPropertySpecification.requiredIf) &&
|
|
211
208
|
childPropertySpecification.requiredIf.predicate(targetValue__expectedToBeObject, this.rawData)) {
|
|
212
|
-
|
|
209
|
+
areOneOnMorePropertiesInvalid = true;
|
|
213
210
|
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
214
211
|
buildConditionallyRequiredPropertyIsMissingWhileRequirementConditionSatisfiedErrorMessage({
|
|
215
212
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
@@ -246,7 +243,7 @@ class RawObjectDataProcessor {
|
|
|
246
243
|
}
|
|
247
244
|
if ((0, isNull_1.default)(childPropertyValue)) {
|
|
248
245
|
if (childPropertySpecification.nullable !== true && (0, isUndefined_1.default)(childPropertySpecification.nullSubstitution)) {
|
|
249
|
-
|
|
246
|
+
areOneOnMorePropertiesInvalid = true;
|
|
250
247
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildNonNullableValueIsNullErrorMessage({
|
|
251
248
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
252
249
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -308,7 +305,7 @@ class RawObjectDataProcessor {
|
|
|
308
305
|
switch (this.processingApproach) {
|
|
309
306
|
case RawObjectDataProcessor.ProcessingApproaches.newObjectAssembling: {
|
|
310
307
|
if ("isInvalid" in childPropertyValueProcessingResult) {
|
|
311
|
-
|
|
308
|
+
areOneOnMorePropertiesInvalid = true;
|
|
312
309
|
continue;
|
|
313
310
|
}
|
|
314
311
|
else if ("isValidButValidationOnlyModeActive" in childPropertyValueProcessingResult) {
|
|
@@ -334,9 +331,9 @@ class RawObjectDataProcessor {
|
|
|
334
331
|
if (!customValidator.validationFunction({
|
|
335
332
|
currentPropertyValue: targetValue__expectedToBeObject,
|
|
336
333
|
rawData__full: this.rawData,
|
|
337
|
-
rawData__currentObjectDepth: parentObject
|
|
334
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
338
335
|
})) {
|
|
339
|
-
|
|
336
|
+
areOneOnMorePropertiesInvalid = true;
|
|
340
337
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
341
338
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
342
339
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -347,7 +344,7 @@ class RawObjectDataProcessor {
|
|
|
347
344
|
}));
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
|
-
if (
|
|
347
|
+
if (areOneOnMorePropertiesInvalid) {
|
|
351
348
|
return { isInvalid: true };
|
|
352
349
|
}
|
|
353
350
|
else if (this.isValidationOnlyMode) {
|
|
@@ -358,8 +355,8 @@ class RawObjectDataProcessor {
|
|
|
358
355
|
processedValueWorkpiece = postValidationModification(processedValueWorkpiece);
|
|
359
356
|
}
|
|
360
357
|
if ((0, isNonEmptyArray_1.default)(targetObjectTypeValueSpecification.propertiesWillBeDeletedAfterPostValidationModifications)) {
|
|
361
|
-
for (const
|
|
362
|
-
delete processedValueWorkpiece[
|
|
358
|
+
for (const keyOfPropertyWhichWillBeDeleted of targetObjectTypeValueSpecification.propertiesWillBeDeletedAfterPostValidationModifications) {
|
|
359
|
+
delete processedValueWorkpiece[keyOfPropertyWhichWillBeDeleted];
|
|
363
360
|
}
|
|
364
361
|
}
|
|
365
362
|
return { processedValue: processedValueWorkpiece };
|
|
@@ -375,11 +372,11 @@ class RawObjectDataProcessor {
|
|
|
375
372
|
}));
|
|
376
373
|
return { isInvalid: true };
|
|
377
374
|
}
|
|
378
|
-
let
|
|
375
|
+
let isTargetIndexedArrayTypeValueInvalid = false;
|
|
379
376
|
if ((0, isNotUndefined_1.default)(targetIndexedArrayTypeValueSpecification.minimalElementsCount) &&
|
|
380
377
|
targetValue__expectedToBeIndexedArray.length < targetIndexedArrayTypeValueSpecification.minimalElementsCount) {
|
|
381
|
-
|
|
382
|
-
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
378
|
+
isTargetIndexedArrayTypeValueInvalid = true;
|
|
379
|
+
this.registerValidationError(this.validationErrorsMessagesBuilder.buildIndexedArrayElementsCountIsLessThanRequiredMinimumErrorMessage({
|
|
383
380
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
384
381
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
385
382
|
targetPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
@@ -391,8 +388,8 @@ class RawObjectDataProcessor {
|
|
|
391
388
|
}
|
|
392
389
|
if ((0, isNotUndefined_1.default)(targetIndexedArrayTypeValueSpecification.maximalElementsCount) &&
|
|
393
390
|
targetValue__expectedToBeIndexedArray.length > targetIndexedArrayTypeValueSpecification.maximalElementsCount) {
|
|
394
|
-
|
|
395
|
-
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
391
|
+
isTargetIndexedArrayTypeValueInvalid = true;
|
|
392
|
+
this.registerValidationError(this.validationErrorsMessagesBuilder.buildIndexedArrayElementsCountIsMoreThanAllowedMaximumErrorMessage({
|
|
396
393
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
397
394
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
398
395
|
targetPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
@@ -404,8 +401,8 @@ class RawObjectDataProcessor {
|
|
|
404
401
|
}
|
|
405
402
|
if ((0, isNotUndefined_1.default)(targetIndexedArrayTypeValueSpecification.exactElementsCount) &&
|
|
406
403
|
targetValue__expectedToBeIndexedArray.length !== targetIndexedArrayTypeValueSpecification.exactElementsCount) {
|
|
407
|
-
|
|
408
|
-
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
404
|
+
isTargetIndexedArrayTypeValueInvalid = true;
|
|
405
|
+
this.registerValidationError(this.validationErrorsMessagesBuilder.buildIndexedArrayElementsCountDoesNotMatchWithSpecifiedExactNumberErrorMessage({
|
|
409
406
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
410
407
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
411
408
|
targetPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
@@ -418,15 +415,15 @@ class RawObjectDataProcessor {
|
|
|
418
415
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.existingObjectManipulation ?
|
|
419
416
|
targetValue__expectedToBeIndexedArray : [];
|
|
420
417
|
const currentObjectDepthLevel__beginWithZero = this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging.length;
|
|
421
|
-
let
|
|
422
|
-
for (const [index,
|
|
418
|
+
let areOneOnMoreElementsInvalid = false;
|
|
419
|
+
for (const [index, rawElement] of targetValue__expectedToBeIndexedArray.entries()) {
|
|
423
420
|
this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging[currentObjectDepthLevel__beginWithZero] = index;
|
|
424
|
-
let element =
|
|
425
|
-
let
|
|
421
|
+
let element = rawElement;
|
|
422
|
+
let stringifiedElementBeforeFirstPreValidationModification;
|
|
426
423
|
const preValidationModifications = RawObjectDataProcessor.
|
|
427
424
|
getNormalizedPreValidationModifications(targetIndexedArrayTypeValueSpecification.element.preValidationModifications);
|
|
428
425
|
if (preValidationModifications.length > 0) {
|
|
429
|
-
|
|
426
|
+
stringifiedElementBeforeFirstPreValidationModification = (0, stringifyAndFormatArbitraryValue_1.default)(rawElement);
|
|
430
427
|
}
|
|
431
428
|
for (const preValidationModification of preValidationModifications) {
|
|
432
429
|
try {
|
|
@@ -438,33 +435,33 @@ class RawObjectDataProcessor {
|
|
|
438
435
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
439
436
|
targetPropertyValue: element,
|
|
440
437
|
targetPropertyValueSpecification: targetIndexedArrayTypeValueSpecification.element,
|
|
441
|
-
targetPropertyStringifiedValueBeforeFirstPreValidationModification:
|
|
438
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: stringifiedElementBeforeFirstPreValidationModification,
|
|
442
439
|
thrownError: error
|
|
443
440
|
}));
|
|
444
441
|
}
|
|
445
442
|
}
|
|
446
443
|
if ((0, isUndefined_1.default)(element)) {
|
|
447
444
|
if (targetIndexedArrayTypeValueSpecification.allowUndefinedTypeElements !== true) {
|
|
448
|
-
|
|
445
|
+
areOneOnMoreElementsInvalid = true;
|
|
449
446
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildIndexedArrayDisallowedUndefinedElementErrorMessage({
|
|
450
447
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
451
448
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
452
449
|
targetPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
453
450
|
targetPropertyValueSpecification: targetIndexedArrayTypeValueSpecification,
|
|
454
|
-
targetPropertyStringifiedValueBeforeFirstPreValidationModification:
|
|
451
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: stringifiedElementBeforeFirstPreValidationModification
|
|
455
452
|
}));
|
|
456
453
|
}
|
|
457
454
|
continue;
|
|
458
455
|
}
|
|
459
456
|
if ((0, isNull_1.default)(element)) {
|
|
460
457
|
if (targetIndexedArrayTypeValueSpecification.allowNullElements !== true) {
|
|
461
|
-
|
|
458
|
+
areOneOnMoreElementsInvalid = true;
|
|
462
459
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildIndexedArrayDisallowedNullElementErrorMessage({
|
|
463
460
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
464
461
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
465
462
|
targetPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
466
463
|
targetPropertyValueSpecification: targetIndexedArrayTypeValueSpecification,
|
|
467
|
-
targetPropertyStringifiedValueBeforeFirstPreValidationModification:
|
|
464
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: stringifiedElementBeforeFirstPreValidationModification
|
|
468
465
|
}));
|
|
469
466
|
}
|
|
470
467
|
continue;
|
|
@@ -473,12 +470,12 @@ class RawObjectDataProcessor {
|
|
|
473
470
|
targetValue: element,
|
|
474
471
|
targetValueSpecification: targetIndexedArrayTypeValueSpecification.element,
|
|
475
472
|
parentObject,
|
|
476
|
-
targetPropertyStringifiedValueBeforeFirstPreValidationModification:
|
|
473
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: stringifiedElementBeforeFirstPreValidationModification
|
|
477
474
|
});
|
|
478
475
|
switch (this.processingApproach) {
|
|
479
476
|
case RawObjectDataProcessor.ProcessingApproaches.newObjectAssembling: {
|
|
480
477
|
if ("isInvalid" in elementProcessingResult) {
|
|
481
|
-
|
|
478
|
+
areOneOnMoreElementsInvalid = true;
|
|
482
479
|
continue;
|
|
483
480
|
}
|
|
484
481
|
else if ("isValidButValidationOnlyModeActive" in elementProcessingResult) {
|
|
@@ -496,9 +493,9 @@ class RawObjectDataProcessor {
|
|
|
496
493
|
if (!customValidator.validationFunction({
|
|
497
494
|
currentPropertyValue: targetValue__expectedToBeIndexedArray,
|
|
498
495
|
rawData__full: this.rawData,
|
|
499
|
-
rawData__currentObjectDepth: parentObject
|
|
496
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
500
497
|
})) {
|
|
501
|
-
|
|
498
|
+
areOneOnMoreElementsInvalid = true;
|
|
502
499
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
503
500
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
504
501
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -509,7 +506,7 @@ class RawObjectDataProcessor {
|
|
|
509
506
|
}));
|
|
510
507
|
}
|
|
511
508
|
}
|
|
512
|
-
if (
|
|
509
|
+
if (isTargetIndexedArrayTypeValueInvalid || areOneOnMoreElementsInvalid) {
|
|
513
510
|
return { isInvalid: true };
|
|
514
511
|
}
|
|
515
512
|
else if (this.isValidationOnlyMode) {
|
|
@@ -522,6 +519,7 @@ class RawObjectDataProcessor {
|
|
|
522
519
|
return { processedValue: processedValueWorkpiece };
|
|
523
520
|
}
|
|
524
521
|
processAssociativeArrayTypeValue({ targetValue__expectedToBeAssociativeArrayTypeObject, targetAssociativeArrayTypeValueSpecification, parentObject, targetPropertyStringifiedValueBeforeFirstPreValidationModification }) {
|
|
522
|
+
var _a, _b;
|
|
525
523
|
if (!(0, isArbitraryObject_1.default)(targetValue__expectedToBeAssociativeArrayTypeObject)) {
|
|
526
524
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildValueTypeDoesNotMatchWithExpectedErrorMessage({
|
|
527
525
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
@@ -532,11 +530,11 @@ class RawObjectDataProcessor {
|
|
|
532
530
|
}));
|
|
533
531
|
return { isInvalid: true };
|
|
534
532
|
}
|
|
535
|
-
let
|
|
533
|
+
let isTargetAssociativeArrayTypeValueInvalid = false;
|
|
536
534
|
if ((0, isNotUndefined_1.default)(targetAssociativeArrayTypeValueSpecification.minimalEntriesCount) &&
|
|
537
535
|
Object.entries(targetValue__expectedToBeAssociativeArrayTypeObject).length <
|
|
538
536
|
targetAssociativeArrayTypeValueSpecification.minimalEntriesCount) {
|
|
539
|
-
|
|
537
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
540
538
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildAssociativeArrayEntriesCountIsLessThanRequiredMinimumErrorMessage({
|
|
541
539
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
542
540
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -550,7 +548,7 @@ class RawObjectDataProcessor {
|
|
|
550
548
|
if ((0, isNotUndefined_1.default)(targetAssociativeArrayTypeValueSpecification.maximalEntriesCount) &&
|
|
551
549
|
Object.entries(targetValue__expectedToBeAssociativeArrayTypeObject).length >
|
|
552
550
|
targetAssociativeArrayTypeValueSpecification.maximalEntriesCount) {
|
|
553
|
-
|
|
551
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
554
552
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildAssociativeArrayPairsCountIsMoreThanAllowedMaximumErrorMessage({
|
|
555
553
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
556
554
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -564,7 +562,7 @@ class RawObjectDataProcessor {
|
|
|
564
562
|
if ((0, isNotUndefined_1.default)(targetAssociativeArrayTypeValueSpecification.exactEntriesCount) &&
|
|
565
563
|
Object.entries(targetValue__expectedToBeAssociativeArrayTypeObject).length !==
|
|
566
564
|
targetAssociativeArrayTypeValueSpecification.exactEntriesCount) {
|
|
567
|
-
|
|
565
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
568
566
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildAssociativeArrayPairsCountDoesNotMatchWithSpecifiedExactNumberErrorMessage({
|
|
569
567
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
570
568
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -579,7 +577,7 @@ class RawObjectDataProcessor {
|
|
|
579
577
|
const missingRequiredKeys = [...targetAssociativeArrayTypeValueSpecification.requiredKeys].
|
|
580
578
|
filter((key) => !Object.keys(targetValue__expectedToBeAssociativeArrayTypeObject).includes(key));
|
|
581
579
|
if (missingRequiredKeys.length > 0) {
|
|
582
|
-
|
|
580
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
583
581
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildRequiredKeysOfAssociativeArrayAreMissingErrorMessage({
|
|
584
582
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
585
583
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -599,7 +597,7 @@ class RawObjectDataProcessor {
|
|
|
599
597
|
}
|
|
600
598
|
}
|
|
601
599
|
if (noOneOfRequiredKeyAlternativeFound) {
|
|
602
|
-
|
|
600
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
603
601
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildRequiredAlternativeKeysOfAssociativeArrayAreMissingErrorMessage({
|
|
604
602
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
605
603
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -618,7 +616,7 @@ class RawObjectDataProcessor {
|
|
|
618
616
|
}
|
|
619
617
|
}
|
|
620
618
|
if (foundDisallowedKeys.length > 0) {
|
|
621
|
-
|
|
619
|
+
isTargetAssociativeArrayTypeValueInvalid = true;
|
|
622
620
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildDisallowedKeysFoundInAssociativeArrayErrorMessage({
|
|
623
621
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
624
622
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -632,13 +630,13 @@ class RawObjectDataProcessor {
|
|
|
632
630
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.existingObjectManipulation ?
|
|
633
631
|
targetValue__expectedToBeAssociativeArrayTypeObject : {};
|
|
634
632
|
const currentObjectDepthLevel__beginWithZero = this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging.length;
|
|
635
|
-
let
|
|
636
|
-
for (const [key,
|
|
633
|
+
let areOneOnMoreValuesInvalid = false;
|
|
634
|
+
for (const [key, rawValue] of Object.entries(targetValue__expectedToBeAssociativeArrayTypeObject)) {
|
|
637
635
|
this.currentlyIteratedObjectPropertyQualifiedNameSegmentsForLogging[currentObjectDepthLevel__beginWithZero] = key;
|
|
638
636
|
if (foundDisallowedKeys.includes(key)) {
|
|
639
637
|
continue;
|
|
640
638
|
}
|
|
641
|
-
let value =
|
|
639
|
+
let value = rawValue;
|
|
642
640
|
let stringifiedValueBeforeFirstPreValidationModification;
|
|
643
641
|
const preValidationModifications = RawObjectDataProcessor.
|
|
644
642
|
getNormalizedPreValidationModifications(targetAssociativeArrayTypeValueSpecification.value.preValidationModifications);
|
|
@@ -660,10 +658,10 @@ class RawObjectDataProcessor {
|
|
|
660
658
|
}));
|
|
661
659
|
}
|
|
662
660
|
}
|
|
663
|
-
const keyFinalName = (
|
|
661
|
+
const keyFinalName = (_b = ((_a = targetAssociativeArrayTypeValueSpecification.keysRenamings) !== null && _a !== void 0 ? _a : {})[key]) !== null && _b !== void 0 ? _b : key;
|
|
664
662
|
if ((0, isUndefined_1.default)(value)) {
|
|
665
663
|
if (targetAssociativeArrayTypeValueSpecification.allowUndefinedTypeValues !== true) {
|
|
666
|
-
|
|
664
|
+
areOneOnMoreValuesInvalid = true;
|
|
667
665
|
this.registerValidationError(this.validationErrorsMessagesBuilder.associativeArrayDisallowedUndefinedValueErrorMessage({
|
|
668
666
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
669
667
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -676,7 +674,7 @@ class RawObjectDataProcessor {
|
|
|
676
674
|
}
|
|
677
675
|
if ((0, isNull_1.default)(value)) {
|
|
678
676
|
if (targetAssociativeArrayTypeValueSpecification.allowNullValues !== true) {
|
|
679
|
-
|
|
677
|
+
areOneOnMoreValuesInvalid = true;
|
|
680
678
|
this.registerValidationError(this.validationErrorsMessagesBuilder.associativeArrayDisallowedNullValueErrorMessage({
|
|
681
679
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
682
680
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -696,7 +694,7 @@ class RawObjectDataProcessor {
|
|
|
696
694
|
switch (this.processingApproach) {
|
|
697
695
|
case RawObjectDataProcessor.ProcessingApproaches.newObjectAssembling: {
|
|
698
696
|
if ("isInvalid" in valueProcessingResult) {
|
|
699
|
-
|
|
697
|
+
areOneOnMoreValuesInvalid = true;
|
|
700
698
|
continue;
|
|
701
699
|
}
|
|
702
700
|
else if ("isValidButValidationOnlyModeActive" in valueProcessingResult) {
|
|
@@ -714,9 +712,9 @@ class RawObjectDataProcessor {
|
|
|
714
712
|
if (!customValidator.validationFunction({
|
|
715
713
|
currentPropertyValue: targetValue__expectedToBeAssociativeArrayTypeObject,
|
|
716
714
|
rawData__full: this.rawData,
|
|
717
|
-
rawData__currentObjectDepth: parentObject
|
|
715
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
718
716
|
})) {
|
|
719
|
-
|
|
717
|
+
areOneOnMoreValuesInvalid = true;
|
|
720
718
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
721
719
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
722
720
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
@@ -727,7 +725,7 @@ class RawObjectDataProcessor {
|
|
|
727
725
|
}));
|
|
728
726
|
}
|
|
729
727
|
}
|
|
730
|
-
if (
|
|
728
|
+
if (isTargetAssociativeArrayTypeValueInvalid || areOneOnMoreValuesInvalid) {
|
|
731
729
|
return { isInvalid: true };
|
|
732
730
|
}
|
|
733
731
|
else if (this.isValidationOnlyMode) {
|
|
@@ -873,7 +871,7 @@ class RawObjectDataProcessor {
|
|
|
873
871
|
}
|
|
874
872
|
if ((0, isNotUndefined_1.default)(targetValueSpecification.allowedAlternatives) &&
|
|
875
873
|
!targetValueSpecification.allowedAlternatives.includes(targetValue__expectedToBeNumber)) {
|
|
876
|
-
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
874
|
+
this.registerValidationError(this.validationErrorsMessagesBuilder.buildValueIsNotAmongAllowedAlternativesErrorMessage({
|
|
877
875
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
878
876
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
879
877
|
targetPropertyValue: targetValue__expectedToBeNumber,
|
|
@@ -911,7 +909,7 @@ class RawObjectDataProcessor {
|
|
|
911
909
|
if (!customValidator.validationFunction({
|
|
912
910
|
currentPropertyValue: targetValue__expectedToBeNumber,
|
|
913
911
|
rawData__full: this.rawData,
|
|
914
|
-
rawData__currentObjectDepth: parentObject
|
|
912
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
915
913
|
})) {
|
|
916
914
|
atLeastOneCustomValidationFailed = true;
|
|
917
915
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
@@ -950,7 +948,7 @@ class RawObjectDataProcessor {
|
|
|
950
948
|
}
|
|
951
949
|
if ((0, isNotUndefined_1.default)(targetValueSpecification.allowedAlternatives) &&
|
|
952
950
|
!targetValueSpecification.allowedAlternatives.includes(targetValue__expectedToBeString)) {
|
|
953
|
-
this.registerValidationError(this.validationErrorsMessagesBuilder.
|
|
951
|
+
this.registerValidationError(this.validationErrorsMessagesBuilder.buildValueIsNotAmongAllowedAlternativesErrorMessage({
|
|
954
952
|
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
955
953
|
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
956
954
|
targetPropertyValue: targetValue__expectedToBeString,
|
|
@@ -1015,7 +1013,7 @@ class RawObjectDataProcessor {
|
|
|
1015
1013
|
if (!customValidator.validationFunction({
|
|
1016
1014
|
currentPropertyValue: targetValue__expectedToBeString,
|
|
1017
1015
|
rawData__full: this.rawData,
|
|
1018
|
-
rawData__currentObjectDepth: parentObject
|
|
1016
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
1019
1017
|
})) {
|
|
1020
1018
|
atLeastOneCustomValidationFailed = true;
|
|
1021
1019
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
@@ -1069,7 +1067,7 @@ class RawObjectDataProcessor {
|
|
|
1069
1067
|
if (!customValidator.validationFunction({
|
|
1070
1068
|
currentPropertyValue: targetValue__expectedToBeBoolean,
|
|
1071
1069
|
rawData__full: this.rawData,
|
|
1072
|
-
rawData__currentObjectDepth: parentObject
|
|
1070
|
+
rawData__currentObjectDepth: parentObject !== null && parentObject !== void 0 ? parentObject : this.rawData
|
|
1073
1071
|
})) {
|
|
1074
1072
|
atLeastOneCustomValidationFailed = true;
|
|
1075
1073
|
this.registerValidationError(this.validationErrorsMessagesBuilder.buildCustomValidationFailedErrorMessageTextData({
|
|
@@ -1096,26 +1094,26 @@ class RawObjectDataProcessor {
|
|
|
1096
1094
|
return { processedValue };
|
|
1097
1095
|
}
|
|
1098
1096
|
processMultipleTypesAllowedValue({ targetValue, targetValueSpecification, parentObject, targetPropertyStringifiedValueBeforeFirstPreValidationModification }) {
|
|
1099
|
-
let
|
|
1097
|
+
let specificationForValueOfCurrentType;
|
|
1100
1098
|
switch (typeof targetValue) {
|
|
1101
1099
|
case "number": {
|
|
1102
|
-
|
|
1100
|
+
specificationForValueOfCurrentType = targetValueSpecification.alternatives.find((alternativeSpecification) => alternativeSpecification.type === RawObjectDataProcessor.ValuesTypesIDs.number ||
|
|
1103
1101
|
alternativeSpecification.type === Number);
|
|
1104
1102
|
break;
|
|
1105
1103
|
}
|
|
1106
1104
|
case "string": {
|
|
1107
|
-
|
|
1105
|
+
specificationForValueOfCurrentType = targetValueSpecification.alternatives.find((alternativeSpecification) => alternativeSpecification.type === RawObjectDataProcessor.ValuesTypesIDs.string ||
|
|
1108
1106
|
alternativeSpecification.type === String);
|
|
1109
1107
|
break;
|
|
1110
1108
|
}
|
|
1111
1109
|
case "boolean": {
|
|
1112
|
-
|
|
1110
|
+
specificationForValueOfCurrentType = targetValueSpecification.alternatives.find((alternativeSpecification) => alternativeSpecification.type === RawObjectDataProcessor.ValuesTypesIDs.boolean ||
|
|
1113
1111
|
alternativeSpecification.type === Boolean);
|
|
1114
1112
|
break;
|
|
1115
1113
|
}
|
|
1116
1114
|
case "object": {
|
|
1117
1115
|
if (Array.isArray(targetValue)) {
|
|
1118
|
-
|
|
1116
|
+
specificationForValueOfCurrentType = targetValueSpecification.alternatives.find((alternativeSpecification) => alternativeSpecification.type === RawObjectDataProcessor.ValuesTypesIDs.indexedArrayOfUniformElements ||
|
|
1119
1117
|
alternativeSpecification.type === Array);
|
|
1120
1118
|
break;
|
|
1121
1119
|
}
|
|
@@ -1127,36 +1125,36 @@ class RawObjectDataProcessor {
|
|
|
1127
1125
|
Logger_1.default.logError({
|
|
1128
1126
|
errorType: InvalidParameterValueError_1.default.NAME,
|
|
1129
1127
|
title: InvalidParameterValueError_1.default.DEFAULT_TITLE,
|
|
1130
|
-
description: this.validationErrorsMessagesBuilder.
|
|
1131
|
-
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
1132
|
-
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
1133
|
-
targetPropertyValue: targetValue,
|
|
1134
|
-
targetPropertyValueSpecification: targetValueSpecification,
|
|
1135
|
-
targetPropertyStringifiedValueBeforeFirstPreValidationModification
|
|
1136
|
-
}),
|
|
1128
|
+
description: this.validationErrorsMessagesBuilder.buildIncompatibleValuesTypesAlternativesErrorDescription(targetValueSpecification),
|
|
1137
1129
|
occurrenceLocation: "RawObjectDataProcessor.processMultipleTypesAllowedValue(parametersObject)"
|
|
1138
1130
|
});
|
|
1139
1131
|
return { isInvalid: true };
|
|
1140
1132
|
}
|
|
1141
|
-
|
|
1133
|
+
specificationForValueOfCurrentType = possibleSpecificationsForObjectValueTypes[0];
|
|
1142
1134
|
break;
|
|
1143
1135
|
}
|
|
1144
1136
|
default: {
|
|
1145
1137
|
break;
|
|
1146
1138
|
}
|
|
1147
1139
|
}
|
|
1148
|
-
if ((0, isUndefined_1.default)(
|
|
1140
|
+
if ((0, isUndefined_1.default)(specificationForValueOfCurrentType)) {
|
|
1149
1141
|
Logger_1.default.logError({
|
|
1150
1142
|
errorType: InvalidParameterValueError_1.default.NAME,
|
|
1151
1143
|
title: InvalidParameterValueError_1.default.DEFAULT_TITLE,
|
|
1152
|
-
description: this.validationErrorsMessagesBuilder.
|
|
1144
|
+
description: this.validationErrorsMessagesBuilder.buildUnsupportedValueTypeErrorDescription({
|
|
1145
|
+
targetPropertyDotSeparatedQualifiedName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
1146
|
+
targetPropertyNewName: this.currentlyIteratedPropertyNewNameForLogging,
|
|
1147
|
+
targetPropertyValue: targetValue,
|
|
1148
|
+
targetPropertyValueSpecification: targetValueSpecification,
|
|
1149
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification
|
|
1150
|
+
}),
|
|
1153
1151
|
occurrenceLocation: "RawObjectDataProcessor.processMultipleTypesAllowedValue(parametersObject)"
|
|
1154
1152
|
});
|
|
1155
1153
|
return { isInvalid: true };
|
|
1156
1154
|
}
|
|
1157
1155
|
return this.processSingleNeitherUndefinedNorNullValue({
|
|
1158
1156
|
targetValue,
|
|
1159
|
-
targetValueSpecification:
|
|
1157
|
+
targetValueSpecification: specificationForValueOfCurrentType,
|
|
1160
1158
|
parentObject,
|
|
1161
1159
|
targetPropertyStringifiedValueBeforeFirstPreValidationModification
|
|
1162
1160
|
});
|
|
@@ -1227,7 +1225,7 @@ RawObjectDataProcessor.defaultLocalization = RawObjectDataProcessorLocalization_
|
|
|
1227
1225
|
return this.localization.rawDataIsNullErrorMessage;
|
|
1228
1226
|
}
|
|
1229
1227
|
buildRawDataIsNotObjectErrorMessage(realType) {
|
|
1230
|
-
return this.localization.
|
|
1228
|
+
return this.localization.buildRawDataIsNotObjectErrorMessage(realType);
|
|
1231
1229
|
}
|
|
1232
1230
|
buildValueTypeDoesNotMatchWithExpectedErrorMessage(payload) {
|
|
1233
1231
|
return this.buildErrorMessage({
|
|
@@ -1262,7 +1260,7 @@ RawObjectDataProcessor.defaultLocalization = RawObjectDataProcessorLocalization_
|
|
|
1262
1260
|
...this.localization.nonNullableValueIsNullErrorMessageTextData
|
|
1263
1261
|
});
|
|
1264
1262
|
}
|
|
1265
|
-
|
|
1263
|
+
buildIndexedArrayElementsCountIsLessThanRequiredMinimumErrorMessage(payload) {
|
|
1266
1264
|
return this.buildErrorMessage({
|
|
1267
1265
|
...payload,
|
|
1268
1266
|
...this.localization.buildIndexedArrayElementsCountIsLessThanRequiredMinimumErrorMessageTextData({
|
|
@@ -1271,7 +1269,7 @@ RawObjectDataProcessor.defaultLocalization = RawObjectDataProcessorLocalization_
|
|
|
1271
1269
|
})
|
|
1272
1270
|
});
|
|
1273
1271
|
}
|
|
1274
|
-
|
|
1272
|
+
buildIndexedArrayElementsCountIsMoreThanAllowedMaximumErrorMessage(payload) {
|
|
1275
1273
|
return this.buildErrorMessage({
|
|
1276
1274
|
...payload,
|
|
1277
1275
|
...this.localization.buildIndexedArrayElementsCountIsMoreThanAllowedMaximumErrorMessageTextData({
|
|
@@ -1280,7 +1278,7 @@ RawObjectDataProcessor.defaultLocalization = RawObjectDataProcessorLocalization_
|
|
|
1280
1278
|
})
|
|
1281
1279
|
});
|
|
1282
1280
|
}
|
|
1283
|
-
|
|
1281
|
+
buildIndexedArrayElementsCountDoesNotMatchWithSpecifiedExactNumberErrorMessage(payload) {
|
|
1284
1282
|
return this.buildErrorMessage({
|
|
1285
1283
|
...payload,
|
|
1286
1284
|
...this.localization.buildIndexedArrayElementsCountDoesNotMatchWithSpecifiedExactNumberErrorMessageTextData({
|
|
@@ -1365,7 +1363,7 @@ RawObjectDataProcessor.defaultLocalization = RawObjectDataProcessorLocalization_
|
|
|
1365
1363
|
...{ expectedNumbersSet: payload.expectedNumbersSet }
|
|
1366
1364
|
});
|
|
1367
1365
|
}
|
|
1368
|
-
|
|
1366
|
+
buildValueIsNotAmongAllowedAlternativesErrorMessage(payload) {
|
|
1369
1367
|
return this.buildErrorMessage({
|
|
1370
1368
|
...payload,
|
|
1371
1369
|
...this.localization.valueIsNotAmongAllowedAlternativesErrorMessageTextData
|