@yamato-daiwa/es-extensions 1.8.6 → 1.8.8
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/AJAX/AJAX_Service.js +1 -1
- package/Distributable/cjs/Numbers/isStringifiedNonNegativeIntegerOfRegularNotation.js +1 -1
- package/Distributable/cjs/Objects/getObjectPropertySafely__TEMP.js +59 -0
- package/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessor.js +166 -70
- package/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessorLocalization.english.js +36 -51
- package/Distributable/esm/AJAX/AJAX_Service.js +1 -1
- package/Distributable/esm/Numbers/isStringifiedNonNegativeIntegerOfRegularNotation.js +1 -1
- package/Distributable/esm/Objects/getObjectPropertySafely__TEMP.d.ts +1 -0
- package/Distributable/esm/Objects/getObjectPropertySafely__TEMP.js +53 -0
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.d.ts +6 -3
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.js +166 -70
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessorLocalization.english.js +36 -51
- package/README.md +235 -364
- package/package.json +1 -1
|
@@ -139,7 +139,7 @@ class AJAX_Service {
|
|
|
139
139
|
Logger_1.default.throwErrorWithFormattedMessage({
|
|
140
140
|
errorInstance: new InvalidConfigError_1.default({
|
|
141
141
|
customMessage: "The \"alternatingURI_PathPart\" has been specified while the static field " +
|
|
142
|
-
"\"
|
|
142
|
+
"\"API_SERVER_URI_CONSTANT_PART__WITHOUT_TRAILING_SLASH\" has not been set."
|
|
143
143
|
}),
|
|
144
144
|
title: InvalidConfigError_1.default.localization.defaultTitle,
|
|
145
145
|
occurrenceLocation: "AJAX_Service.normalizeURI_UntilPath(URI_PathRawDefinition)"
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = isStringifiedNonNegativeIntegerOfRegularNotation;
|
|
4
4
|
function isStringifiedNonNegativeIntegerOfRegularNotation(value) {
|
|
5
|
-
return (/^[1-9]\d
|
|
5
|
+
return (/^(?:0|^[1-9]\d*)$/u).test(value);
|
|
6
6
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getObjectPropertySafely;
|
|
7
|
+
const splitString_1 = __importDefault(require("../Strings/splitString"));
|
|
8
|
+
const Logger_1 = __importDefault(require("../Logging/Logger"));
|
|
9
|
+
const InvalidParameterValueError_1 = __importDefault(require("../Errors/InvalidParameterValue/InvalidParameterValueError"));
|
|
10
|
+
const isNonEmptyString_1 = __importDefault(require("../TypeGuards/Strings/isNonEmptyString"));
|
|
11
|
+
const isArbitraryObject_1 = __importDefault(require("../TypeGuards/Objects/isArbitraryObject"));
|
|
12
|
+
const isNaturalNumberOrZero_1 = __importDefault(require("../TypeGuards/Numbers/isNaturalNumberOrZero"));
|
|
13
|
+
function getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty) {
|
|
14
|
+
if (!(0, isArbitraryObject_1.default)(targetObject)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let targetPropertyPathSegments;
|
|
18
|
+
if (Array.isArray(dotSeparatedOrArrayedPathToTargetProperty) &&
|
|
19
|
+
dotSeparatedOrArrayedPathToTargetProperty.length > 0 &&
|
|
20
|
+
dotSeparatedOrArrayedPathToTargetProperty.
|
|
21
|
+
every((key) => (0, isNonEmptyString_1.default)(key) || (0, isNaturalNumberOrZero_1.default)(key))) {
|
|
22
|
+
targetPropertyPathSegments = dotSeparatedOrArrayedPathToTargetProperty;
|
|
23
|
+
}
|
|
24
|
+
else if ((0, isNaturalNumberOrZero_1.default)(dotSeparatedOrArrayedPathToTargetProperty)) {
|
|
25
|
+
targetPropertyPathSegments = [String(dotSeparatedOrArrayedPathToTargetProperty)];
|
|
26
|
+
}
|
|
27
|
+
else if ((0, isNonEmptyString_1.default)(dotSeparatedOrArrayedPathToTargetProperty)) {
|
|
28
|
+
targetPropertyPathSegments = (0, splitString_1.default)(dotSeparatedOrArrayedPathToTargetProperty, ".");
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
Logger_1.default.logError({
|
|
32
|
+
errorType: InvalidParameterValueError_1.default.NAME,
|
|
33
|
+
title: InvalidParameterValueError_1.default.localization.defaultTitle,
|
|
34
|
+
description: InvalidParameterValueError_1.default.localization.generateDescription({
|
|
35
|
+
parameterNumber: 2,
|
|
36
|
+
parameterName: "dotSeparatedOrArrayedPathToTargetProperty",
|
|
37
|
+
messageSpecificPart: "This parameter must be either a non-empty string, or a non-negative integer, or a non-empty array " +
|
|
38
|
+
"of strings and/or non-negative integers."
|
|
39
|
+
}),
|
|
40
|
+
occurrenceLocation: "getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty)"
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let objectOfCurrentDepthLevel = targetObject;
|
|
45
|
+
for (let depthLevel__numerationFrom1 = 1; depthLevel__numerationFrom1 <= targetPropertyPathSegments.length; depthLevel__numerationFrom1++) {
|
|
46
|
+
const isLastDepthLevel = depthLevel__numerationFrom1 === targetPropertyPathSegments.length;
|
|
47
|
+
const valueOfCurrentDepthLevel = objectOfCurrentDepthLevel[targetPropertyPathSegments[depthLevel__numerationFrom1 - 1]];
|
|
48
|
+
if (isLastDepthLevel) {
|
|
49
|
+
return valueOfCurrentDepthLevel;
|
|
50
|
+
}
|
|
51
|
+
else if ((0, isArbitraryObject_1.default)(valueOfCurrentDepthLevel)) {
|
|
52
|
+
objectOfCurrentDepthLevel = valueOfCurrentDepthLevel;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
@@ -30,6 +30,8 @@ const isEitherUndefinedOrNull_1 = __importDefault(require("../TypeGuards/EmptyTy
|
|
|
30
30
|
const isNeitherUndefinedNorNull_1 = __importDefault(require("../TypeGuards/EmptyTypes/isNeitherUndefinedNorNull"));
|
|
31
31
|
const emptyStringToNull_1 = __importDefault(require("../ValueTransformers/emptyStringToNull"));
|
|
32
32
|
const getLastElementOfArray_1 = __importDefault(require("../Arrays/01-RetrievingOfElements/getLastElementOfArray"));
|
|
33
|
+
const ValuesDeepCopier_1 = __importDefault(require("../ValuesDeepCopier"));
|
|
34
|
+
const getObjectPropertySafely__TEMP_1 = __importDefault(require("../Objects/getObjectPropertySafely__TEMP"));
|
|
33
35
|
class RawObjectDataProcessor {
|
|
34
36
|
static defaultLocalization = RawObjectDataProcessorLocalization_english_1.default;
|
|
35
37
|
rawData;
|
|
@@ -37,8 +39,9 @@ class RawObjectDataProcessor {
|
|
|
37
39
|
localization;
|
|
38
40
|
errorHandlingStrategies;
|
|
39
41
|
validationErrorsMessages = [];
|
|
40
|
-
|
|
42
|
+
currentlyIteratedPropertyQualifiedInitialNameSegments = [];
|
|
41
43
|
currentlyIteratedPropertyNewNamesByDepthLevelsForLogging = [];
|
|
44
|
+
initialObjectSnapshot;
|
|
42
45
|
static process(rawData, validDataSpecification, options = {}) {
|
|
43
46
|
const localization = options.localization ?? RawObjectDataProcessor.defaultLocalization;
|
|
44
47
|
if (typeof rawData !== "object") {
|
|
@@ -155,6 +158,15 @@ class RawObjectDataProcessor {
|
|
|
155
158
|
onUnableToUpdatePropertyValue: errorHandlingStrategies.onUnableToUpdatePropertyValue ??
|
|
156
159
|
RawObjectDataProcessor.ErrorHandlingStrategies.throwingOfError
|
|
157
160
|
};
|
|
161
|
+
switch (this.processingApproach) {
|
|
162
|
+
case RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject: {
|
|
163
|
+
this.initialObjectSnapshot = this.rawData;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject: {
|
|
167
|
+
this.initialObjectSnapshot = null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
158
170
|
}
|
|
159
171
|
processFixedSchemaObjectTypeValue({ targetObjectTypeValueSpecification, parentObject, targetPropertyStringifiedValueBeforeFirstPreValidationModification, ...compoundParameter }) {
|
|
160
172
|
let targetObjectTypeSourceValue;
|
|
@@ -186,7 +198,7 @@ class RawObjectDataProcessor {
|
|
|
186
198
|
}
|
|
187
199
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject ?
|
|
188
200
|
targetObjectTypeSourceValue : {};
|
|
189
|
-
const currentObjectDepthLevel__countFromZero = this.
|
|
201
|
+
const currentObjectDepthLevel__countFromZero = this.currentlyIteratedPropertyQualifiedInitialNameSegments.length;
|
|
190
202
|
const initialNamesOfNotCheckedYetProperties = new Set(Object.keys(targetObjectTypeSourceValue));
|
|
191
203
|
let hasAtLeastOneInvalidPropertyBeenDetected = false;
|
|
192
204
|
let hasAllChildrenPropertiesValuesDefinitelyNotChanged = true;
|
|
@@ -199,7 +211,8 @@ class RawObjectDataProcessor {
|
|
|
199
211
|
if (possibleSchema.actualIf({
|
|
200
212
|
rawData__currentObjectDepth: targetObjectTypeSourceValue,
|
|
201
213
|
rawData__full: this.rawData,
|
|
202
|
-
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName
|
|
214
|
+
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
215
|
+
targetPropertyPathSegments: [...this.currentlyIteratedPropertyQualifiedInitialNameSegments]
|
|
203
216
|
})) {
|
|
204
217
|
propertiesSpecification = possibleSchema.properties;
|
|
205
218
|
break;
|
|
@@ -220,11 +233,13 @@ class RawObjectDataProcessor {
|
|
|
220
233
|
}
|
|
221
234
|
for (const [childPropertyInitialName, childPropertySpecification] of Object.entries(propertiesSpecification)) {
|
|
222
235
|
initialNamesOfNotCheckedYetProperties.delete(childPropertyInitialName);
|
|
223
|
-
this.
|
|
236
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments[currentObjectDepthLevel__countFromZero] =
|
|
237
|
+
childPropertyInitialName;
|
|
224
238
|
let childPropertyFinalName;
|
|
225
239
|
if ((0, isUndefined_1.default)(childPropertySpecification.newName)) {
|
|
226
240
|
childPropertyFinalName = childPropertyInitialName;
|
|
227
241
|
this.currentlyIteratedPropertyNewNamesByDepthLevelsForLogging[currentObjectDepthLevel__countFromZero] = null;
|
|
242
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
228
243
|
}
|
|
229
244
|
else {
|
|
230
245
|
childPropertyFinalName = childPropertySpecification.newName;
|
|
@@ -257,6 +272,7 @@ class RawObjectDataProcessor {
|
|
|
257
272
|
(0, ArbitraryValueFormatter_1.stringifyAndFormatArbitraryValue)(childPropertyMutableValue);
|
|
258
273
|
hasChildPropertyValueDefinitelyNotChanged = false;
|
|
259
274
|
hasAllChildrenPropertiesValuesDefinitelyNotChanged = false;
|
|
275
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
260
276
|
}
|
|
261
277
|
for (const preValidationModification of preValidationModifications) {
|
|
262
278
|
try {
|
|
@@ -301,10 +317,23 @@ class RawObjectDataProcessor {
|
|
|
301
317
|
continue;
|
|
302
318
|
}
|
|
303
319
|
if ((0, isNotUndefined_1.default)(childPropertySpecification.undefinedForbiddenIf)) {
|
|
320
|
+
const rawData__full = this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
321
|
+
let rawData__currentObjectDepth;
|
|
322
|
+
switch (this.processingApproach) {
|
|
323
|
+
case RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject: {
|
|
324
|
+
rawData__currentObjectDepth = targetObjectTypeSourceValue;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject: {
|
|
328
|
+
rawData__currentObjectDepth =
|
|
329
|
+
(0, getObjectPropertySafely__TEMP_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
304
332
|
if (childPropertySpecification.undefinedForbiddenIf.predicate({
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName
|
|
333
|
+
rawData__full,
|
|
334
|
+
rawData__currentObjectDepth,
|
|
335
|
+
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
336
|
+
targetPropertyPathSegments: [...this.currentlyIteratedPropertyQualifiedInitialNameSegments]
|
|
308
337
|
})) {
|
|
309
338
|
hasAtLeastOneInvalidPropertyBeenDetected = true;
|
|
310
339
|
this.registerValidationError({
|
|
@@ -324,30 +353,45 @@ class RawObjectDataProcessor {
|
|
|
324
353
|
}
|
|
325
354
|
}
|
|
326
355
|
else if ((0, isNotUndefined_1.default)(childPropertySpecification.undefinedValueSubstitution)) {
|
|
356
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
327
357
|
childPropertyMutableValue = childPropertySpecification.undefinedValueSubstitution;
|
|
328
358
|
hasChildPropertyValueDefinitelyNotChanged = false;
|
|
329
359
|
hasAllChildrenPropertiesValuesDefinitelyNotChanged = false;
|
|
330
360
|
}
|
|
331
361
|
}
|
|
332
|
-
else if ("mustBeUndefinedIf" in childPropertySpecification
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
362
|
+
else if ("mustBeUndefinedIf" in childPropertySpecification) {
|
|
363
|
+
const rawData__full = this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
364
|
+
let rawData__currentObjectDepth;
|
|
365
|
+
switch (this.processingApproach) {
|
|
366
|
+
case RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject: {
|
|
367
|
+
rawData__currentObjectDepth = targetObjectTypeSourceValue;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject: {
|
|
371
|
+
rawData__currentObjectDepth =
|
|
372
|
+
(0, getObjectPropertySafely__TEMP_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (childPropertySpecification.mustBeUndefinedIf?.predicate({
|
|
376
|
+
rawData__currentObjectDepth,
|
|
377
|
+
rawData__full,
|
|
378
|
+
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
379
|
+
targetPropertyPathSegments: [...this.currentlyIteratedPropertyQualifiedInitialNameSegments]
|
|
337
380
|
}) === true) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
381
|
+
this.registerValidationError({
|
|
382
|
+
title: this.localization.validationErrors.conditionallyForbiddenNonUndefinedValue.title,
|
|
383
|
+
description: this.localization.validationErrors.conditionallyForbiddenNonUndefinedValue.generateDescription({
|
|
384
|
+
verbalConditionWhenMustBeUndefinedWithoutEndOfSentenceMark: childPropertySpecification.mustBeUndefinedIf.descriptionForLogging
|
|
385
|
+
}),
|
|
386
|
+
targetPropertyDotSeparatedQualifiedInitialName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
387
|
+
targetPropertyNewName: childPropertySpecification.newName ?? null,
|
|
388
|
+
targetPropertyValue: childPropertyMutableValue,
|
|
389
|
+
targetPropertyValueSpecification: childPropertySpecification,
|
|
390
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: childPropertyStringifiedValueBeforeFirstPreValidationModification,
|
|
391
|
+
documentationPageAnchor: "VALIDATION_ERRORS_MESSAGES-CONDITIONALLY_FORBIDDEN_NON_UNDEFINED_VALUE"
|
|
392
|
+
});
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
351
395
|
}
|
|
352
396
|
if (!(0, isBoolean_1.default)(childPropertySpecification.isNullForbidden) &&
|
|
353
397
|
(0, isUndefined_1.default)(childPropertySpecification.nullForbiddenIf) &&
|
|
@@ -379,10 +423,23 @@ class RawObjectDataProcessor {
|
|
|
379
423
|
continue;
|
|
380
424
|
}
|
|
381
425
|
if ((0, isNotUndefined_1.default)(childPropertySpecification.nullForbiddenIf)) {
|
|
426
|
+
const rawData__full = this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
427
|
+
let rawData__currentObjectDepth;
|
|
428
|
+
switch (this.processingApproach) {
|
|
429
|
+
case RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject: {
|
|
430
|
+
rawData__currentObjectDepth = targetObjectTypeSourceValue;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
case RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject: {
|
|
434
|
+
rawData__currentObjectDepth =
|
|
435
|
+
(0, getObjectPropertySafely__TEMP_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
382
438
|
if (childPropertySpecification.nullForbiddenIf.predicate({
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName
|
|
439
|
+
rawData__full,
|
|
440
|
+
rawData__currentObjectDepth,
|
|
441
|
+
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
442
|
+
targetPropertyPathSegments: [...this.currentlyIteratedPropertyQualifiedInitialNameSegments]
|
|
386
443
|
})) {
|
|
387
444
|
hasAtLeastOneInvalidPropertyBeenDetected = true;
|
|
388
445
|
this.registerValidationError({
|
|
@@ -402,30 +459,45 @@ class RawObjectDataProcessor {
|
|
|
402
459
|
}
|
|
403
460
|
}
|
|
404
461
|
else if ((0, isNotUndefined_1.default)(childPropertySpecification.nullValueSubstitution)) {
|
|
462
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
405
463
|
childPropertyMutableValue = childPropertySpecification.nullValueSubstitution;
|
|
406
464
|
hasChildPropertyValueDefinitelyNotChanged = false;
|
|
407
465
|
hasAllChildrenPropertiesValuesDefinitelyNotChanged = false;
|
|
408
466
|
}
|
|
409
467
|
}
|
|
410
|
-
else if ("mustBeNullIf" in childPropertySpecification
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
468
|
+
else if ("mustBeNullIf" in childPropertySpecification) {
|
|
469
|
+
const rawData__full = this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
470
|
+
let rawData__currentObjectDepth;
|
|
471
|
+
switch (this.processingApproach) {
|
|
472
|
+
case RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject: {
|
|
473
|
+
rawData__currentObjectDepth = targetObjectTypeSourceValue;
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
case RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject: {
|
|
477
|
+
rawData__currentObjectDepth =
|
|
478
|
+
(0, getObjectPropertySafely__TEMP_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1).join("."));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (childPropertySpecification.mustBeNullIf?.predicate({
|
|
482
|
+
rawData__currentObjectDepth,
|
|
483
|
+
rawData__full,
|
|
484
|
+
targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
485
|
+
targetPropertyPathSegments: [...this.currentlyIteratedPropertyQualifiedInitialNameSegments]
|
|
415
486
|
}) === true) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
487
|
+
this.registerValidationError({
|
|
488
|
+
title: this.localization.validationErrors.conditionallyForbiddenNonNullValue.title,
|
|
489
|
+
description: this.localization.validationErrors.conditionallyForbiddenNonNullValue.generateDescription({
|
|
490
|
+
verbalConditionWhenMustBeNullWithoutEndOfSentenceMark: childPropertySpecification.mustBeNullIf.descriptionForLogging
|
|
491
|
+
}),
|
|
492
|
+
targetPropertyDotSeparatedQualifiedInitialName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
493
|
+
targetPropertyNewName: childPropertySpecification.newName ?? null,
|
|
494
|
+
targetPropertyValue: childPropertyMutableValue,
|
|
495
|
+
targetPropertyValueSpecification: childPropertySpecification,
|
|
496
|
+
targetPropertyStringifiedValueBeforeFirstPreValidationModification: childPropertyStringifiedValueBeforeFirstPreValidationModification,
|
|
497
|
+
documentationPageAnchor: "VALIDATION_ERRORS_MESSAGES-CONDITIONALLY_FORBIDDEN_NON_NULL_VALUE"
|
|
498
|
+
});
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
429
501
|
}
|
|
430
502
|
if ((0, isNeitherUndefinedNorNull_1.default)(childPropertyMutableValue)) {
|
|
431
503
|
const childPropertyValueProcessingResult = this.processSingleNeitherUndefinedNorNullValue({
|
|
@@ -608,7 +680,7 @@ class RawObjectDataProcessor {
|
|
|
608
680
|
}
|
|
609
681
|
}
|
|
610
682
|
}
|
|
611
|
-
this.
|
|
683
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments.splice(-1, 1);
|
|
612
684
|
this.currentlyIteratedPropertyNewNamesByDepthLevelsForLogging.splice(-1, 1);
|
|
613
685
|
if (targetObjectTypeValueSpecification.mustExpectOnlySpecifiedProperties === true &&
|
|
614
686
|
initialNamesOfNotCheckedYetProperties.size > 0) {
|
|
@@ -654,8 +726,12 @@ class RawObjectDataProcessor {
|
|
|
654
726
|
else if (this.isValidationOnlyMode) {
|
|
655
727
|
return { thisOneIsValidButPostProcessingDisabledForPerformanceBecauseDataIsInvalidInLarge: true };
|
|
656
728
|
}
|
|
657
|
-
|
|
658
|
-
getNormalizedPostValidationModifications(targetObjectTypeValueSpecification.postValidationModifications)
|
|
729
|
+
const normalizedPostValidationModifications = RawObjectDataProcessor.
|
|
730
|
+
getNormalizedPostValidationModifications(targetObjectTypeValueSpecification.postValidationModifications);
|
|
731
|
+
if (normalizedPostValidationModifications.length > 0) {
|
|
732
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
733
|
+
}
|
|
734
|
+
for (const postValidationModification of normalizedPostValidationModifications) {
|
|
659
735
|
processedValueWorkpiece = postValidationModification(processedValueWorkpiece);
|
|
660
736
|
}
|
|
661
737
|
for (const keyOfPropertyWhichWillBeDeleted of targetObjectTypeValueSpecification.propertiesWillBeDeletedAfterPostValidationModifications ?? []) {
|
|
@@ -775,7 +851,7 @@ class RawObjectDataProcessor {
|
|
|
775
851
|
}
|
|
776
852
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject ?
|
|
777
853
|
targetObjectTypeSourceValue : {};
|
|
778
|
-
const currentObjectDepthLevel__countFromZero = this.
|
|
854
|
+
const currentObjectDepthLevel__countFromZero = this.currentlyIteratedPropertyQualifiedInitialNameSegments.length;
|
|
779
855
|
let hasAtLeastOneInvalidValueBeenDetected = false;
|
|
780
856
|
const forbiddenKeys = targetAssociativeArrayTypeValueSpecification.forbiddenKeys ?? [];
|
|
781
857
|
let allowedKeys;
|
|
@@ -800,8 +876,7 @@ class RawObjectDataProcessor {
|
|
|
800
876
|
let hasAllEntriesDefinitelyNotChanged = true;
|
|
801
877
|
const foundDisallowedKeys = [];
|
|
802
878
|
for (const [initialKey, rawValue] of Object.entries(targetObjectTypeSourceValue)) {
|
|
803
|
-
this.
|
|
804
|
-
initialKey;
|
|
879
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments[currentObjectDepthLevel__countFromZero] = initialKey;
|
|
805
880
|
if (!allowedKeys.includes(initialKey)) {
|
|
806
881
|
foundDisallowedKeys.push(initialKey);
|
|
807
882
|
}
|
|
@@ -810,8 +885,9 @@ class RawObjectDataProcessor {
|
|
|
810
885
|
if ((0, isNotNull_1.default)(newNameOfKey)) {
|
|
811
886
|
this.currentlyIteratedPropertyNewNamesByDepthLevelsForLogging[currentObjectDepthLevel__countFromZero] =
|
|
812
887
|
newNameOfKey;
|
|
888
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
813
889
|
}
|
|
814
|
-
if (hasAllEntriesDefinitelyNotChanged &&
|
|
890
|
+
if (hasAllEntriesDefinitelyNotChanged && (0, isNotNull_1.default)(newNameOfKey)) {
|
|
815
891
|
hasAllEntriesDefinitelyNotChanged = false;
|
|
816
892
|
}
|
|
817
893
|
let hasValueDefinitelyNotChanged = true;
|
|
@@ -828,6 +904,7 @@ class RawObjectDataProcessor {
|
|
|
828
904
|
stringifiedValueBeforeFirstPreValidationModification = (0, ArbitraryValueFormatter_1.stringifyAndFormatArbitraryValue)(mutableValue);
|
|
829
905
|
hasValueDefinitelyNotChanged = false;
|
|
830
906
|
hasAllEntriesDefinitelyNotChanged = false;
|
|
907
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
831
908
|
}
|
|
832
909
|
for (const preValidationModification of preValidationModifications) {
|
|
833
910
|
try {
|
|
@@ -963,7 +1040,7 @@ class RawObjectDataProcessor {
|
|
|
963
1040
|
}
|
|
964
1041
|
}
|
|
965
1042
|
}
|
|
966
|
-
this.
|
|
1043
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments.splice(-1, 1);
|
|
967
1044
|
this.currentlyIteratedPropertyNewNamesByDepthLevelsForLogging.splice(-1, 1);
|
|
968
1045
|
if (foundDisallowedKeys.length > 0) {
|
|
969
1046
|
hasTargetAssociativeArraySpecificEntryIndependentViolations = true;
|
|
@@ -1007,8 +1084,12 @@ class RawObjectDataProcessor {
|
|
|
1007
1084
|
else if (this.isValidationOnlyMode) {
|
|
1008
1085
|
return { thisOneIsValidButPostProcessingDisabledForPerformanceBecauseDataIsInvalidInLarge: true };
|
|
1009
1086
|
}
|
|
1010
|
-
|
|
1011
|
-
getNormalizedPostValidationModifications(targetAssociativeArrayTypeValueSpecification.postValidationModifications)
|
|
1087
|
+
const normalizedPostValidationModifications = RawObjectDataProcessor.
|
|
1088
|
+
getNormalizedPostValidationModifications(targetAssociativeArrayTypeValueSpecification.postValidationModifications);
|
|
1089
|
+
if (normalizedPostValidationModifications.length > 0) {
|
|
1090
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
1091
|
+
}
|
|
1092
|
+
for (const postValidationModification of normalizedPostValidationModifications) {
|
|
1012
1093
|
processedValueWorkpiece = postValidationModification(processedValueWorkpiece);
|
|
1013
1094
|
}
|
|
1014
1095
|
return {
|
|
@@ -1118,12 +1199,11 @@ class RawObjectDataProcessor {
|
|
|
1118
1199
|
}
|
|
1119
1200
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject ?
|
|
1120
1201
|
targetArrayedTypeSourceValue : [];
|
|
1121
|
-
const currentObjectDepthLevel__beginWithZero = this.
|
|
1202
|
+
const currentObjectDepthLevel__beginWithZero = this.currentlyIteratedPropertyQualifiedInitialNameSegments.length;
|
|
1122
1203
|
let hasAtLeastOneInvalidElementBeenDetected = false;
|
|
1123
1204
|
let hasAllElementsDefinitelyNotChanged = true;
|
|
1124
1205
|
for (const [index, rawElement] of targetArrayedTypeSourceValue.entries()) {
|
|
1125
|
-
this.
|
|
1126
|
-
index;
|
|
1206
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments[currentObjectDepthLevel__beginWithZero] = index;
|
|
1127
1207
|
let hasElementDefinitelyNotChanged = true;
|
|
1128
1208
|
const preValidationModifications = RawObjectDataProcessor.
|
|
1129
1209
|
getNormalizedPreValidationModifications({
|
|
@@ -1138,6 +1218,7 @@ class RawObjectDataProcessor {
|
|
|
1138
1218
|
stringifiedElementBeforeFirstPreValidationModification = (0, ArbitraryValueFormatter_1.stringifyAndFormatArbitraryValue)(mutableElement);
|
|
1139
1219
|
hasElementDefinitelyNotChanged = false;
|
|
1140
1220
|
hasAllElementsDefinitelyNotChanged = false;
|
|
1221
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
1141
1222
|
}
|
|
1142
1223
|
for (const preValidationModification of preValidationModifications) {
|
|
1143
1224
|
try {
|
|
@@ -1217,7 +1298,7 @@ class RawObjectDataProcessor {
|
|
|
1217
1298
|
}
|
|
1218
1299
|
}
|
|
1219
1300
|
}
|
|
1220
|
-
this.
|
|
1301
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments.splice(-1, 1);
|
|
1221
1302
|
for (const customValidator of RawObjectDataProcessor.getNormalizedCustomValidators(targetIndexedArrayTypeValueSpecification.customValidators)) {
|
|
1222
1303
|
if (!customValidator.validationFunction({
|
|
1223
1304
|
value: targetArrayedTypeSourceValue,
|
|
@@ -1246,8 +1327,12 @@ class RawObjectDataProcessor {
|
|
|
1246
1327
|
else if (this.isValidationOnlyMode) {
|
|
1247
1328
|
return { thisOneIsValidButPostProcessingDisabledForPerformanceBecauseDataIsInvalidInLarge: true };
|
|
1248
1329
|
}
|
|
1249
|
-
|
|
1250
|
-
getNormalizedPostValidationModifications(targetIndexedArrayTypeValueSpecification.postValidationModifications)
|
|
1330
|
+
const normalizedPostValidationModifications = RawObjectDataProcessor.
|
|
1331
|
+
getNormalizedPostValidationModifications(targetIndexedArrayTypeValueSpecification.postValidationModifications);
|
|
1332
|
+
if (normalizedPostValidationModifications.length > 0) {
|
|
1333
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
1334
|
+
}
|
|
1335
|
+
for (const postValidationModification of normalizedPostValidationModifications) {
|
|
1251
1336
|
processedValueWorkpiece = postValidationModification(processedValueWorkpiece);
|
|
1252
1337
|
}
|
|
1253
1338
|
return {
|
|
@@ -1322,13 +1407,12 @@ class RawObjectDataProcessor {
|
|
|
1322
1407
|
}
|
|
1323
1408
|
let processedValueWorkpiece = this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.manipulationsWithSourceObject ?
|
|
1324
1409
|
targetArrayedTypeSourceValue : [];
|
|
1325
|
-
const currentObjectDepthLevel__beginWithZero = this.
|
|
1410
|
+
const currentObjectDepthLevel__beginWithZero = this.currentlyIteratedPropertyQualifiedInitialNameSegments.length;
|
|
1326
1411
|
let hasAtLeastOneInvalidElementBeenDetected = false;
|
|
1327
1412
|
let hasAllElementsDefinitelyNotChanged = true;
|
|
1328
1413
|
for (const [elementStringifiedIndex, elementSpecification] of Object.entries(targetTupleTypeValueSpecification.elements)) {
|
|
1329
1414
|
const elementIndex = Number.parseInt(elementStringifiedIndex, 10);
|
|
1330
|
-
this.
|
|
1331
|
-
elementIndex;
|
|
1415
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments[currentObjectDepthLevel__beginWithZero] = elementIndex;
|
|
1332
1416
|
let hasElementDefinitelyNotChanged = true;
|
|
1333
1417
|
const preValidationModifications = RawObjectDataProcessor.
|
|
1334
1418
|
getNormalizedPreValidationModifications({
|
|
@@ -1342,6 +1426,7 @@ class RawObjectDataProcessor {
|
|
|
1342
1426
|
stringifiedElementBeforeFirstPreValidationModification = (0, ArbitraryValueFormatter_1.stringifyAndFormatArbitraryValue)(mutableElement);
|
|
1343
1427
|
hasElementDefinitelyNotChanged = false;
|
|
1344
1428
|
hasAllElementsDefinitelyNotChanged = false;
|
|
1429
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
1345
1430
|
}
|
|
1346
1431
|
for (const preValidationModification of preValidationModifications) {
|
|
1347
1432
|
try {
|
|
@@ -1546,7 +1631,7 @@ class RawObjectDataProcessor {
|
|
|
1546
1631
|
}
|
|
1547
1632
|
}
|
|
1548
1633
|
}
|
|
1549
|
-
this.
|
|
1634
|
+
this.currentlyIteratedPropertyQualifiedInitialNameSegments.splice(-1, 1);
|
|
1550
1635
|
for (const customValidator of RawObjectDataProcessor.getNormalizedCustomValidators(targetTupleTypeValueSpecification.customValidators)) {
|
|
1551
1636
|
if (!customValidator.validationFunction({
|
|
1552
1637
|
value: targetArrayedTypeSourceValue,
|
|
@@ -1575,8 +1660,12 @@ class RawObjectDataProcessor {
|
|
|
1575
1660
|
else if (this.isValidationOnlyMode) {
|
|
1576
1661
|
return { thisOneIsValidButPostProcessingDisabledForPerformanceBecauseDataIsInvalidInLarge: true };
|
|
1577
1662
|
}
|
|
1578
|
-
|
|
1579
|
-
getNormalizedPostValidationModifications(targetTupleTypeValueSpecification.postValidationModifications)
|
|
1663
|
+
const normalizedPostValidationModifications = RawObjectDataProcessor.
|
|
1664
|
+
getNormalizedPostValidationModifications(targetTupleTypeValueSpecification.postValidationModifications);
|
|
1665
|
+
if (normalizedPostValidationModifications.length > 0) {
|
|
1666
|
+
this.createInitialObjectSnapshotIfNotCreatedYet();
|
|
1667
|
+
}
|
|
1668
|
+
for (const postValidationModification of normalizedPostValidationModifications) {
|
|
1580
1669
|
processedValueWorkpiece = postValidationModification(processedValueWorkpiece);
|
|
1581
1670
|
}
|
|
1582
1671
|
return {
|
|
@@ -1961,7 +2050,7 @@ class RawObjectDataProcessor {
|
|
|
1961
2050
|
description: this.localization.validationErrors.valueTypeDoesNotMatchWithExpected.
|
|
1962
2051
|
generateDescription({
|
|
1963
2052
|
actualNativeType: typeof targetValue__expectedToBeString,
|
|
1964
|
-
expectedTypeID: RawObjectDataProcessor.ValuesTypesIDs.
|
|
2053
|
+
expectedTypeID: RawObjectDataProcessor.ValuesTypesIDs.string
|
|
1965
2054
|
}),
|
|
1966
2055
|
targetPropertyDotSeparatedQualifiedInitialName: this.currentObjectPropertyDotSeparatedQualifiedName,
|
|
1967
2056
|
targetPropertyNewName: (0, getLastElementOfArray_1.default)(this.currentlyIteratedPropertyNewNamesByDepthLevelsForLogging),
|
|
@@ -2292,11 +2381,18 @@ class RawObjectDataProcessor {
|
|
|
2292
2381
|
});
|
|
2293
2382
|
}
|
|
2294
2383
|
get currentObjectPropertyDotSeparatedQualifiedName() {
|
|
2295
|
-
return this.
|
|
2384
|
+
return this.currentlyIteratedPropertyQualifiedInitialNameSegments.join(".");
|
|
2296
2385
|
}
|
|
2297
2386
|
registerValidationError(payload) {
|
|
2298
2387
|
this.validationErrorsMessages.push(RawObjectDataProcessor.generateValidationErrorMessage(payload, this.localization));
|
|
2299
2388
|
}
|
|
2389
|
+
createInitialObjectSnapshotIfNotCreatedYet() {
|
|
2390
|
+
if (this.processingApproach === RawObjectDataProcessor.ProcessingApproaches.assemblingOfNewObject) {
|
|
2391
|
+
return this.rawData;
|
|
2392
|
+
}
|
|
2393
|
+
return this.initialObjectSnapshot ??
|
|
2394
|
+
(this.initialObjectSnapshot = ValuesDeepCopier_1.default.deeplyCloneObjectLikeValueAsPossible(this.rawData));
|
|
2395
|
+
}
|
|
2300
2396
|
handleFailedPreValidationModification({ error, propertyOrElementMutableValue, propertyOrElementValueSpecification, propertyOrElementStringifiedValueBeforeFirstPreValidationModification, occurrenceMethodName }) {
|
|
2301
2397
|
switch (this.errorHandlingStrategies.onPreValidationModificationFailed) {
|
|
2302
2398
|
case RawObjectDataProcessor.ErrorHandlingStrategies.throwingOfError: {
|