@yamato-daiwa/es-extensions 1.9.0-alpha.4 → 1.9.0

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.
@@ -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
- "\"API_SERVER_URI_CONSTANT_PART\" has not been set."
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*$/u).test(value);
5
+ return (/^(?:0|^[1-9]\d*)$/u).test(value);
6
6
  }
@@ -9,44 +9,47 @@ const Logger_1 = __importDefault(require("../Logging/Logger"));
9
9
  const InvalidParameterValueError_1 = __importDefault(require("../Errors/InvalidParameterValue/InvalidParameterValueError"));
10
10
  const isNonEmptyString_1 = __importDefault(require("../TypeGuards/Strings/isNonEmptyString"));
11
11
  const isArbitraryObject_1 = __importDefault(require("../TypeGuards/Objects/isArbitraryObject"));
12
+ const isNaturalNumberOrZero_1 = __importDefault(require("../TypeGuards/Numbers/isNaturalNumberOrZero"));
12
13
  function getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty) {
13
- if (!(0, isNonEmptyString_1.default)(dotSeparatedOrArrayedPathToTargetProperty) &&
14
- (!Array.isArray(dotSeparatedOrArrayedPathToTargetProperty) ||
15
- dotSeparatedOrArrayedPathToTargetProperty.some((key) => !(0, isNonEmptyString_1.default)(key)))) {
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 {
16
31
  Logger_1.default.logError({
17
32
  errorType: InvalidParameterValueError_1.default.NAME,
18
33
  title: InvalidParameterValueError_1.default.localization.defaultTitle,
19
34
  description: InvalidParameterValueError_1.default.localization.generateDescription({
20
35
  parameterNumber: 2,
21
36
  parameterName: "dotSeparatedOrArrayedPathToTargetProperty",
22
- messageSpecificPart: "This parameter must be either non-empty string or array of non-empty strings."
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."
23
39
  }),
24
40
  occurrenceLocation: "getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty)"
25
41
  });
26
42
  return;
27
43
  }
28
- if (!(0, isArbitraryObject_1.default)(targetObject)) {
29
- return;
30
- }
31
- let targetPropertyPathSegments;
32
- if (Array.isArray(dotSeparatedOrArrayedPathToTargetProperty)) {
33
- targetPropertyPathSegments = dotSeparatedOrArrayedPathToTargetProperty;
34
- }
35
- else {
36
- targetPropertyPathSegments = (0, splitString_1.default)(dotSeparatedOrArrayedPathToTargetProperty, ".");
37
- }
38
- if (targetPropertyPathSegments.length === 0) {
39
- return;
40
- }
41
44
  let objectOfCurrentDepthLevel = targetObject;
42
- for (let depthLevel = 1; depthLevel <= targetPropertyPathSegments.length; depthLevel++) {
43
- const isLastDepthLevel = depthLevel === targetPropertyPathSegments.length;
44
- const valueOfNextDepthLevel = objectOfCurrentDepthLevel[targetPropertyPathSegments[depthLevel - 1]];
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]];
45
48
  if (isLastDepthLevel) {
46
- return valueOfNextDepthLevel;
49
+ return valueOfCurrentDepthLevel;
47
50
  }
48
- else if ((0, isArbitraryObject_1.default)(valueOfNextDepthLevel)) {
49
- objectOfCurrentDepthLevel = valueOfNextDepthLevel;
51
+ else if ((0, isArbitraryObject_1.default)(valueOfCurrentDepthLevel)) {
52
+ objectOfCurrentDepthLevel = valueOfCurrentDepthLevel;
50
53
  }
51
54
  else {
52
55
  return;
@@ -0,0 +1,51 @@
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 = setObjectProperties;
7
+ const splitString_1 = __importDefault(require("../Strings/splitString"));
8
+ const isNonNullObject_1 = __importDefault(require("../TypeGuards/Objects/isNonNullObject"));
9
+ const isUndefined_1 = __importDefault(require("../TypeGuards/EmptyTypes/isUndefined"));
10
+ const isStringifiedNonNegativeIntegerOfRegularNotation_1 = __importDefault(require("../Numbers/isStringifiedNonNegativeIntegerOfRegularNotation"));
11
+ function setObjectProperties(targetObject, order) {
12
+ for (const [fullyQualifiedName, propertyDescriptor] of Object.entries(order)) {
13
+ const targetPropertyPathSegments = (0, splitString_1.default)(fullyQualifiedName, ".");
14
+ let objectOfCurrentDepthLevel = targetObject;
15
+ for (let depthLevel__numerationFrom1 = 1; depthLevel__numerationFrom1 <= targetPropertyPathSegments.length; depthLevel__numerationFrom1++) {
16
+ const isLastDepthLevel = depthLevel__numerationFrom1 === targetPropertyPathSegments.length;
17
+ const propertyKeyForCurrentDepthLevel = targetPropertyPathSegments[depthLevel__numerationFrom1 - 1];
18
+ let valueOfNextDepthLevel = Reflect.get(objectOfCurrentDepthLevel, propertyKeyForCurrentDepthLevel);
19
+ if (isLastDepthLevel) {
20
+ if ((0, isNonNullObject_1.default)(objectOfCurrentDepthLevel)) {
21
+ Object.defineProperty(objectOfCurrentDepthLevel, propertyKeyForCurrentDepthLevel, {
22
+ value: propertyDescriptor.value,
23
+ enumerable: propertyDescriptor.enumerable ?? true,
24
+ configurable: propertyDescriptor.configurable ?? true,
25
+ writable: propertyDescriptor.writable ?? true
26
+ });
27
+ }
28
+ else {
29
+ return;
30
+ }
31
+ }
32
+ else if ((0, isNonNullObject_1.default)(valueOfNextDepthLevel)) {
33
+ objectOfCurrentDepthLevel = valueOfNextDepthLevel;
34
+ }
35
+ else if ((0, isUndefined_1.default)(valueOfNextDepthLevel) && propertyDescriptor.mustCreateParentsObjectsIfNotPresent === true) {
36
+ const propertyKeyForNextDepthLevel = targetPropertyPathSegments[depthLevel__numerationFrom1];
37
+ valueOfNextDepthLevel = (0, isStringifiedNonNegativeIntegerOfRegularNotation_1.default)(propertyKeyForNextDepthLevel) ? [] : {};
38
+ Object.defineProperty(objectOfCurrentDepthLevel, propertyKeyForCurrentDepthLevel, {
39
+ value: valueOfNextDepthLevel,
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true
43
+ });
44
+ objectOfCurrentDepthLevel = valueOfNextDepthLevel;
45
+ }
46
+ else {
47
+ return;
48
+ }
49
+ }
50
+ }
51
+ }
@@ -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_1 = __importDefault(require("../Objects/getObjectPropertySafely"));
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
- currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging = [];
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.length;
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging[currentObjectDepthLevel__countFromZero] = childPropertyInitialName;
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_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1));
330
+ }
331
+ }
304
332
  if (childPropertySpecification.undefinedForbiddenIf.predicate({
305
- rawData__currentObjectDepth: targetObjectTypeSourceValue,
306
- rawData__full: this.rawData,
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
- childPropertySpecification.mustBeUndefinedIf?.predicate({
334
- rawData__currentObjectDepth: targetObjectTypeSourceValue,
335
- rawData__full: this.rawData,
336
- targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName
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_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
- this.registerValidationError({
339
- title: this.localization.validationErrors.conditionallyForbiddenNonUndefinedValue.title,
340
- description: this.localization.validationErrors.conditionallyForbiddenNonUndefinedValue.generateDescription({
341
- verbalConditionWhenMustBeUndefinedWithoutEndOfSentenceMark: childPropertySpecification.mustBeUndefinedIf.descriptionForLogging
342
- }),
343
- targetPropertyDotSeparatedQualifiedInitialName: this.currentObjectPropertyDotSeparatedQualifiedName,
344
- targetPropertyNewName: childPropertySpecification.newName ?? null,
345
- targetPropertyValue: childPropertyMutableValue,
346
- targetPropertyValueSpecification: childPropertySpecification,
347
- targetPropertyStringifiedValueBeforeFirstPreValidationModification: childPropertyStringifiedValueBeforeFirstPreValidationModification,
348
- documentationPageAnchor: "VALIDATION_ERRORS_MESSAGES-CONDITIONALLY_FORBIDDEN_NON_UNDEFINED_VALUE"
349
- });
350
- continue;
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_1.default)(rawData__full, this.currentlyIteratedPropertyQualifiedInitialNameSegments.slice(0, -1));
436
+ }
437
+ }
382
438
  if (childPropertySpecification.nullForbiddenIf.predicate({
383
- rawData__currentObjectDepth: targetObjectTypeSourceValue,
384
- rawData__full: this.rawData,
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
- childPropertySpecification.mustBeNullIf?.predicate({
412
- rawData__currentObjectDepth: targetObjectTypeSourceValue,
413
- rawData__full: this.rawData,
414
- targetPropertyDotSeparatedPath: this.currentObjectPropertyDotSeparatedQualifiedName
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_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
- this.registerValidationError({
417
- title: this.localization.validationErrors.conditionallyForbiddenNonNullValue.title,
418
- description: this.localization.validationErrors.conditionallyForbiddenNonNullValue.generateDescription({
419
- verbalConditionWhenMustBeNullWithoutEndOfSentenceMark: childPropertySpecification.mustBeNullIf.descriptionForLogging
420
- }),
421
- targetPropertyDotSeparatedQualifiedInitialName: this.currentObjectPropertyDotSeparatedQualifiedName,
422
- targetPropertyNewName: childPropertySpecification.newName ?? null,
423
- targetPropertyValue: childPropertyMutableValue,
424
- targetPropertyValueSpecification: childPropertySpecification,
425
- targetPropertyStringifiedValueBeforeFirstPreValidationModification: childPropertyStringifiedValueBeforeFirstPreValidationModification,
426
- documentationPageAnchor: "VALIDATION_ERRORS_MESSAGES-CONDITIONALLY_FORBIDDEN_NON_NULL_VALUE"
427
- });
428
- continue;
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.splice(-1, 1);
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
- for (const postValidationModification of RawObjectDataProcessor.
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.length;
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging[currentObjectDepthLevel__countFromZero] =
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 && finalKey !== initialKey) {
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.splice(-1, 1);
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
- for (const postValidationModification of RawObjectDataProcessor.
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.length;
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging[currentObjectDepthLevel__beginWithZero] =
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.splice(-1, 1);
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
- for (const postValidationModification of RawObjectDataProcessor.
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.length;
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging[currentObjectDepthLevel__beginWithZero] =
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.splice(-1, 1);
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
- for (const postValidationModification of RawObjectDataProcessor.
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.number
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.currentlyIteratedObjectPropertyQualifiedInitialNameSegmentsForLogging.join(".");
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: {