@yamato-daiwa/es-extensions 1.8.7 → 1.8.9
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 +58 -0
- package/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessor.js +174 -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 +52 -0
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.d.ts +6 -3
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessor.js +174 -70
- package/Distributable/esm/RawObjectDataProcessor/RawObjectDataProcessorLocalization.english.js +36 -51
- package/README.md +235 -364
- package/package.json +1 -1
package/Distributable/cjs/RawObjectDataProcessor/RawObjectDataProcessorLocalization.english.js
CHANGED
|
@@ -53,9 +53,7 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
53
53
|
preValidationModificationFailed: {
|
|
54
54
|
title: "Pre-validation Modification Failed",
|
|
55
55
|
generateDescription: ({ stringifiedCaughtError }) => "The following error has occurred during the pre-validation modification of this property/element. \n" +
|
|
56
|
-
|
|
57
|
-
"The data has been marked as invalid because the error handling strategy \"onPreValidationModificationFailed\" " +
|
|
58
|
-
"is \"ErrorHandlingStrategies.markingOfDataAsInvalid\" what is not recommended. "
|
|
56
|
+
stringifiedCaughtError
|
|
59
57
|
},
|
|
60
58
|
forbiddenUndefinedValue: {
|
|
61
59
|
title: "Forbidden Undefined Value",
|
|
@@ -112,22 +110,23 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
112
110
|
},
|
|
113
111
|
associativeArrayEntriesCountIsLessThanRequiredMinimum: {
|
|
114
112
|
title: "Too Few Entries in Associative Array",
|
|
115
|
-
generateDescription: ({ actualEntriesCount, minimalEntriesCount }) => `This value of associative array has ${actualEntriesCount} entries while at least ` +
|
|
113
|
+
generateDescription: ({ actualEntriesCount, minimalEntriesCount }) => `This value of associative array type has ${actualEntriesCount} entries while at least ` +
|
|
116
114
|
`${minimalEntriesCount} expected.`
|
|
117
115
|
},
|
|
118
116
|
associativeArrayPairsCountIsMoreThanAllowedMaximum: {
|
|
119
117
|
title: "Too Many Entries in Associative Array",
|
|
120
|
-
generateDescription: ({ maximalEntriesCount, actualEntriesCount }) => `This value of associative array has ${actualEntriesCount} entries while maximally ` +
|
|
118
|
+
generateDescription: ({ maximalEntriesCount, actualEntriesCount }) => `This value of associative array type has ${actualEntriesCount} entries while maximally ` +
|
|
121
119
|
`${maximalEntriesCount} expected.`
|
|
122
120
|
},
|
|
123
121
|
associativeArrayPairsCountDoesNotMatchWithSpecifiedExactNumber: {
|
|
124
122
|
title: "Wrong Exact Number of Entries in Associative Array",
|
|
125
|
-
generateDescription: ({ exactEntriesCount, actualEntriesCount }) => `This value of associative array has ${exactEntriesCount} entries while exactly ${actualEntriesCount}
|
|
123
|
+
generateDescription: ({ exactEntriesCount, actualEntriesCount }) => `This value of associative array type has ${exactEntriesCount} entries while exactly ${actualEntriesCount} ` +
|
|
124
|
+
"expected."
|
|
126
125
|
},
|
|
127
126
|
forbiddenForSpecificKeysUndefinedOrNullValuesFoundInAssociativeArrayTypeObject: {
|
|
128
|
-
title: "Forbidden for Specific Keys Undefined or Null Values
|
|
129
|
-
generateDescription: ({ keysOfEitherUndefinedOrNullValues }) => "The values of the following keys are either null or
|
|
130
|
-
"been
|
|
127
|
+
title: "Forbidden for Specific Keys of the Associative Array Undefined or Null Values",
|
|
128
|
+
generateDescription: ({ keysOfEitherUndefinedOrNullValues }) => "The values of the following keys are either null or undefined while for these keys such values has " +
|
|
129
|
+
"been forbidden.\n" +
|
|
131
130
|
keysOfEitherUndefinedOrNullValues.
|
|
132
131
|
map((keyOfEitherUndefinedOrNullValue) => ` ● ${keyOfEitherUndefinedOrNullValue}`).
|
|
133
132
|
join("\n")
|
|
@@ -141,12 +140,12 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
141
140
|
},
|
|
142
141
|
indexedArrayElementsCountIsLessThanRequiredMinimum: {
|
|
143
142
|
title: "Too Few Elements in Indexed Array",
|
|
144
|
-
generateDescription: ({ minimalElementsCount, actualElementsCount }) => `This value of indexed array has ${actualElementsCount} elements while at least ` +
|
|
143
|
+
generateDescription: ({ minimalElementsCount, actualElementsCount }) => `This value of indexed array type has ${actualElementsCount} elements while at least ` +
|
|
145
144
|
`${minimalElementsCount} expected.`
|
|
146
145
|
},
|
|
147
146
|
indexedArrayElementsCountIsMoreThanAllowedMaximum: {
|
|
148
|
-
title: "
|
|
149
|
-
generateDescription: ({ maximalElementsCount, actualElementsCount }) => `This value of indexed array has ${actualElementsCount} elements while maximally ` +
|
|
147
|
+
title: "Too Many Elements in Indexed Array",
|
|
148
|
+
generateDescription: ({ maximalElementsCount, actualElementsCount }) => `This value of indexed array type has ${actualElementsCount} elements while maximally ` +
|
|
150
149
|
`${maximalElementsCount} expected.`
|
|
151
150
|
},
|
|
152
151
|
indexedArrayOrTupleElementsCountDoesNotMatchWithSpecifiedExactNumber: {
|
|
@@ -156,24 +155,26 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
156
155
|
},
|
|
157
156
|
forbiddenNaN_Value: {
|
|
158
157
|
title: "Forbidden NaN Value Of Numeric Property/Element",
|
|
159
|
-
description: "The value of this numeric property or element is NaN while it has been
|
|
158
|
+
description: "The value of this numeric property or element is NaN while it has not been allowed. "
|
|
160
159
|
},
|
|
161
160
|
numericValueIsNotBelongToExpectedNumbersSet: {
|
|
162
161
|
title: "Expected and Actual Numbers Set Mismatch",
|
|
163
162
|
generateDescription: ({ expectedNumberSet }) => "Contrary to expectations, this numeric value is not member of " +
|
|
164
|
-
`"${rawObjectDataProcessorLocalization__english.getLocalizedNumbersSet(expectedNumberSet)}"
|
|
163
|
+
`"${rawObjectDataProcessorLocalization__english.getLocalizedNumbersSet(expectedNumberSet)}" number set.`
|
|
165
164
|
},
|
|
166
165
|
valueIsNotAmongAllowedAlternatives: {
|
|
167
166
|
title: "Disallowed Alternative of Value",
|
|
168
167
|
generateDescription: ({ allowedAlternatives }) => "This value is not among following allowed alternatives:\n" +
|
|
169
|
-
allowedAlternatives.
|
|
168
|
+
allowedAlternatives.
|
|
169
|
+
map((allowedAlternative) => ` ○ ${allowedAlternative}`).
|
|
170
|
+
join("\n")
|
|
170
171
|
},
|
|
171
172
|
numericValueIsSmallerThanRequiredMinimum: {
|
|
172
173
|
title: "Minimal Value Fall Short",
|
|
173
174
|
generateDescription: ({ requiredMinimum }) => `This value is smaller than required minimal value ${requiredMinimum}.`
|
|
174
175
|
},
|
|
175
176
|
numericValueIsGreaterThanAllowedMaximum: {
|
|
176
|
-
title: "Maximal
|
|
177
|
+
title: "Maximal Value Exceeding",
|
|
177
178
|
generateDescription: ({ allowedMaximum }) => `This value is greater than allowed maximal value ${allowedMaximum}.`
|
|
178
179
|
},
|
|
179
180
|
charactersCountIsLessThanRequired: {
|
|
@@ -186,7 +187,7 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
186
187
|
},
|
|
187
188
|
charactersCountDoesNotMatchWithSpecified: {
|
|
188
189
|
title: "Fixed Characters Count Mismatch",
|
|
189
|
-
generateDescription: ({ fixedCharactersCount, realCharactersCount }) => `The value has ${realCharactersCount} characters while exactly ${fixedCharactersCount}
|
|
190
|
+
generateDescription: ({ fixedCharactersCount, realCharactersCount }) => `The value has ${realCharactersCount} characters while exactly ${fixedCharactersCount} required.`
|
|
190
191
|
},
|
|
191
192
|
forbiddenCharactersFound: {
|
|
192
193
|
title: "Forbidden Characters",
|
|
@@ -216,47 +217,45 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
216
217
|
mutuallyExclusiveTransformationsBetweenUndefinedAndNull: {
|
|
217
218
|
title: "Mutually Exclusive Transformations Between Undefined and Null",
|
|
218
219
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "Both \"mustTransformUndefinedToNull\" and \"mustTransformNullToUndefined\" options has been specified with " +
|
|
219
|
-
|
|
220
|
+
`\`true\` value for the property "${targetPropertyDotSeparatedQualifiedName}" what is the contradiction. ` +
|
|
220
221
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
221
222
|
},
|
|
222
223
|
preValidationModificationFailed: {
|
|
223
224
|
title: "Pre-validation Modification Failed",
|
|
224
225
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "The error has occurred during the pre-validation modification of the property/element " +
|
|
225
226
|
`"${targetPropertyDotSeparatedQualifiedName}". ` +
|
|
226
|
-
"This error has been thrown because the error handling strategy \"onPreValidationModificationFailed\" is " +
|
|
227
|
-
"\"ErrorHandlingStrategies.throwingOfError\" which is the default one. " +
|
|
228
227
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
229
228
|
},
|
|
230
229
|
propertyUndefinedabilityNotSpecified: {
|
|
231
230
|
title: "Property Undefinedability has not been Specified",
|
|
232
231
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "It has not been specified how to process the undefined value of the property " +
|
|
233
|
-
|
|
232
|
+
`"${targetPropertyDotSeparatedQualifiedName}". ` +
|
|
234
233
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
235
234
|
},
|
|
236
235
|
propertyNullabilityNotSpecified: {
|
|
237
236
|
title: "Property Nullability has not been Specified",
|
|
238
237
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "It has not been specified how to process the null value of the property " +
|
|
239
|
-
|
|
238
|
+
`"${targetPropertyDotSeparatedQualifiedName}". ` +
|
|
240
239
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
241
240
|
},
|
|
242
241
|
dataTypeNotSpecified: {
|
|
243
242
|
title: "Unsupported or Not Specified Data Type",
|
|
244
243
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, specifiedStringifiedType, documentationPageAnchor }) => ((0, isUndefined_1.default)(specifiedStringifiedType) ?
|
|
245
|
-
"Data type has not
|
|
246
|
-
`Unsupported data type "${specifiedStringifiedType} has
|
|
247
|
-
`specified for property/element "${targetPropertyDotSeparatedQualifiedName}". ` +
|
|
244
|
+
"Data type has not " :
|
|
245
|
+
`Unsupported data type "${specifiedStringifiedType} has "`) +
|
|
246
|
+
`been specified for property/element "${targetPropertyDotSeparatedQualifiedName}". ` +
|
|
248
247
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
249
248
|
},
|
|
250
249
|
unableToDeletePropertyWithOutdatedKey: {
|
|
251
250
|
title: "Unable to Delete Property With Outdated Key",
|
|
252
|
-
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, propertyNewKey, documentationPageAnchor }) => `Unable to delete the property "${targetPropertyDotSeparatedQualifiedName}" after
|
|
253
|
-
`"${propertyNewKey}" because it is not configurable while the processing approach is the
|
|
254
|
-
"with source object and \"mustLeaveEvenRenamed\" has not been set to true
|
|
251
|
+
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, propertyNewKey, documentationPageAnchor }) => `Unable to delete the property "${targetPropertyDotSeparatedQualifiedName}" after creating of its copy ` +
|
|
252
|
+
`with name "${propertyNewKey}" because it is not configurable while the processing approach is the ` +
|
|
253
|
+
"manipulations with source object and \"mustLeaveEvenRenamed\" has not been set to `true`. " +
|
|
255
254
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
256
255
|
},
|
|
257
256
|
unableToChangePropertyDescriptors: {
|
|
258
257
|
title: "Unable to Change Property Descriptors",
|
|
259
|
-
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => `Unable to change the
|
|
258
|
+
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => `Unable to change the description of property "${targetPropertyDotSeparatedQualifiedName}" because this ` +
|
|
260
259
|
"property is not configurable while the processing approach is the manipulations with source object. " +
|
|
261
260
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
262
261
|
},
|
|
@@ -272,8 +271,7 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
272
271
|
((0, isNull_1.default)(targetPropertyDotSeparatedQualifiedName) ?
|
|
273
272
|
"root associative array " :
|
|
274
273
|
`associative array "${targetPropertyDotSeparatedQualifiedName}" `) +
|
|
275
|
-
"what it the contradiction. " +
|
|
276
|
-
"Either allowed keys or forbidden ones can be specified but not both." +
|
|
274
|
+
" what it the contradiction. " +
|
|
277
275
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
278
276
|
},
|
|
279
277
|
incompatibleValuesTypesAlternatives: {
|
|
@@ -282,14 +280,13 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
282
280
|
(isIndexedArrayLikeType ?
|
|
283
281
|
"`ValuesTypesIDs.indexedArray` (aliased as `Array`) and `ValuesTypesIDs.tuple`" :
|
|
284
282
|
"`ValuesTypesIDs.fixedSchemaObject` (aliased as `Object`) and `ValuesTypesIDs.associativeArray`") +
|
|
285
|
-
"are incompatible alternatives of `ValuesTypesIDs.polymorphic` because from the viewpoint of ECMAScript " +
|
|
286
|
-
|
|
287
|
-
(isIndexedArrayLikeType ? "`Array`" : "`Object`") +
|
|
283
|
+
" are incompatible alternatives of `ValuesTypesIDs.polymorphic` because from the viewpoint of ECMAScript " +
|
|
284
|
+
`both are the ${isIndexedArrayLikeType ? "`Array`" : "`Object`"}. ` +
|
|
288
285
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
289
286
|
},
|
|
290
287
|
bothAllowedAndForbiddenCharactersSpecified: {
|
|
291
288
|
title: "Both Allowed And Forbidden Characters Specified",
|
|
292
|
-
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "Both allowed and forbidden characters has been specified for string-type property/element " +
|
|
289
|
+
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => "Both allowed and forbidden characters has been specified for the string-type property/element " +
|
|
293
290
|
`${targetPropertyDotSeparatedQualifiedName} what it the contradiction. ` +
|
|
294
291
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
295
292
|
}
|
|
@@ -300,37 +297,25 @@ const rawObjectDataProcessorLocalization__english = {
|
|
|
300
297
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, stringifiedCaughtError, documentationPageAnchor }) => "The error has occurred during the pre-validation modification of the property/element " +
|
|
301
298
|
`"${targetPropertyDotSeparatedQualifiedName}".\n` +
|
|
302
299
|
`${stringifiedCaughtError}\n` +
|
|
303
|
-
"This error has been reported as warning because the error handling strategy " +
|
|
304
|
-
"\"onPreValidationModificationFailed\" is \"ErrorHandlingStrategies.warningWithoutMarkingOfDataAsInvalid\" " +
|
|
305
|
-
"what is not recommended. " +
|
|
306
300
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
307
301
|
},
|
|
308
302
|
unableToDeletePropertyWithOutdatedKey: {
|
|
309
303
|
title: "Unable to Delete Property With Outdated Key",
|
|
310
|
-
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, propertyNewKey, documentationPageAnchor }) => `Unable to delete the property "${targetPropertyDotSeparatedQualifiedName}" after
|
|
311
|
-
`"${propertyNewKey}" because it is not configurable while the processing approach is the
|
|
312
|
-
"with source object and \"mustLeaveEvenRenamed\" has not been set to true
|
|
313
|
-
"This error has been reported as warning because the error handling strategy " +
|
|
314
|
-
"\"unableToChangePropertyDescriptors\" is \"ErrorHandlingStrategies.warningWithoutMarkingOfDataAsInvalid\" " +
|
|
315
|
-
"what is not recommended. " +
|
|
304
|
+
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, propertyNewKey, documentationPageAnchor }) => `Unable to delete the property "${targetPropertyDotSeparatedQualifiedName}" after creating of its copy ` +
|
|
305
|
+
`with name "${propertyNewKey}" because it is not configurable while the processing approach is the ` +
|
|
306
|
+
"manipulations with source object and \"mustLeaveEvenRenamed\" has not been set to `true`. " +
|
|
316
307
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
317
308
|
},
|
|
318
309
|
unableToChangePropertyDescriptors: {
|
|
319
310
|
title: "Unable to Change Property Descriptors",
|
|
320
|
-
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => `Unable to change the
|
|
311
|
+
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => `Unable to change the description of property "${targetPropertyDotSeparatedQualifiedName}" because this ` +
|
|
321
312
|
"property is not configurable while the processing approach is the manipulations with source object. " +
|
|
322
|
-
"This error has been reported as warning because the error handling strategy " +
|
|
323
|
-
"\"unableToChangePropertyDescriptors\" is \"ErrorHandlingStrategies.warningWithoutMarkingOfDataAsInvalid\" " +
|
|
324
|
-
"what is not recommended. " +
|
|
325
313
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
326
314
|
},
|
|
327
315
|
unableToUpdatePropertyValue: {
|
|
328
316
|
title: "Unable to Update property Value",
|
|
329
317
|
generateDescription: ({ targetPropertyDotSeparatedQualifiedName, documentationPageAnchor }) => `The updating of the property "${targetPropertyDotSeparatedQualifiedName}" has been requested via default ` +
|
|
330
318
|
"value substitution or pre-validation modification while this property is read-only. " +
|
|
331
|
-
"This error has been reported as warning because the error handling strategy " +
|
|
332
|
-
"\"unableToChangePropertyDescriptors\" is \"ErrorHandlingStrategies.warningWithoutMarkingOfDataAsInvalid\" " +
|
|
333
|
-
"what is not recommended. " +
|
|
334
319
|
rawObjectDataProcessorLocalization__english.generateSeeMoreSentence({ documentationPageAnchor })
|
|
335
320
|
}
|
|
336
321
|
},
|
|
@@ -134,7 +134,7 @@ class AJAX_Service {
|
|
|
134
134
|
Logger.throwErrorWithFormattedMessage({
|
|
135
135
|
errorInstance: new InvalidConfigError({
|
|
136
136
|
customMessage: "The \"alternatingURI_PathPart\" has been specified while the static field " +
|
|
137
|
-
"\"
|
|
137
|
+
"\"API_SERVER_URI_CONSTANT_PART__WITHOUT_TRAILING_SLASH\" has not been set."
|
|
138
138
|
}),
|
|
139
139
|
title: InvalidConfigError.localization.defaultTitle,
|
|
140
140
|
occurrenceLocation: "AJAX_Service.normalizeURI_UntilPath(URI_PathRawDefinition)"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getObjectPropertySafely(targetObject: unknown, dotSeparatedOrArrayedPathToTargetProperty: ReadonlyArray<string | number> | string | number): unknown;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import splitString from "../Strings/splitString";
|
|
2
|
+
import Logger from "../Logging/Logger";
|
|
3
|
+
import InvalidParameterValueError from "../Errors/InvalidParameterValue/InvalidParameterValueError";
|
|
4
|
+
import isNonEmptyString from "../TypeGuards/Strings/isNonEmptyString";
|
|
5
|
+
import isArbitraryObject from "../TypeGuards/Objects/isArbitraryObject";
|
|
6
|
+
import isNaturalNumberOrZero from "../TypeGuards/Numbers/isNaturalNumberOrZero";
|
|
7
|
+
export default function getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty) {
|
|
8
|
+
if (!isArbitraryObject(targetObject)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let targetPropertyPathSegments;
|
|
12
|
+
if (Array.isArray(dotSeparatedOrArrayedPathToTargetProperty) &&
|
|
13
|
+
dotSeparatedOrArrayedPathToTargetProperty.length > 0 &&
|
|
14
|
+
dotSeparatedOrArrayedPathToTargetProperty.
|
|
15
|
+
every((key) => isNonEmptyString(key) || isNaturalNumberOrZero(key))) {
|
|
16
|
+
targetPropertyPathSegments = dotSeparatedOrArrayedPathToTargetProperty;
|
|
17
|
+
}
|
|
18
|
+
else if (isNaturalNumberOrZero(dotSeparatedOrArrayedPathToTargetProperty)) {
|
|
19
|
+
targetPropertyPathSegments = [String(dotSeparatedOrArrayedPathToTargetProperty)];
|
|
20
|
+
}
|
|
21
|
+
else if (isNonEmptyString(dotSeparatedOrArrayedPathToTargetProperty)) {
|
|
22
|
+
targetPropertyPathSegments = splitString(dotSeparatedOrArrayedPathToTargetProperty, ".");
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
Logger.throwErrorWithFormattedMessage({
|
|
26
|
+
errorInstance: new InvalidParameterValueError({
|
|
27
|
+
parameterNumber: 2,
|
|
28
|
+
parameterName: "dotSeparatedOrArrayedPathToTargetProperty",
|
|
29
|
+
messageSpecificPart: "This parameter must be either a non-empty string, or a non-negative integer, or a non-empty array " +
|
|
30
|
+
"of strings and/or non-negative integers."
|
|
31
|
+
}),
|
|
32
|
+
title: InvalidParameterValueError.localization.defaultTitle,
|
|
33
|
+
occurrenceLocation: "getObjectPropertySafely(targetObject, dotSeparatedOrArrayedPathToTargetProperty)"
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let objectOfCurrentDepthLevel = targetObject;
|
|
38
|
+
for (let depthLevel__numerationFrom1 = 1; depthLevel__numerationFrom1 <= targetPropertyPathSegments.length; depthLevel__numerationFrom1++) {
|
|
39
|
+
const isLastDepthLevel = depthLevel__numerationFrom1 === targetPropertyPathSegments.length;
|
|
40
|
+
const valueOfCurrentDepthLevel = objectOfCurrentDepthLevel[targetPropertyPathSegments[depthLevel__numerationFrom1 - 1]];
|
|
41
|
+
if (isLastDepthLevel) {
|
|
42
|
+
return valueOfCurrentDepthLevel;
|
|
43
|
+
}
|
|
44
|
+
else if (isArbitraryObject(valueOfCurrentDepthLevel)) {
|
|
45
|
+
objectOfCurrentDepthLevel = valueOfCurrentDepthLevel;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
@@ -7,8 +7,9 @@ declare class RawObjectDataProcessor {
|
|
|
7
7
|
private readonly localization;
|
|
8
8
|
private readonly errorHandlingStrategies;
|
|
9
9
|
private readonly validationErrorsMessages;
|
|
10
|
-
private readonly
|
|
10
|
+
private readonly currentlyIteratedPropertyQualifiedInitialNameSegments;
|
|
11
11
|
private readonly currentlyIteratedPropertyNewNamesByDepthLevelsForLogging;
|
|
12
|
+
private initialObjectSnapshot;
|
|
12
13
|
static process<ProcessedData extends PossiblyReadonlyParsedJSON, InterimValidData = ProcessedData>(rawData: unknown, validDataSpecification: RawObjectDataProcessor.ObjectDataSpecification, options?: RawObjectDataProcessor.Options): RawObjectDataProcessor.ProcessingResult<ProcessedData>;
|
|
13
14
|
static formatValidationErrorsList(messages: ReadonlyArray<string>, localization?: RawObjectDataProcessor.Localization): string;
|
|
14
15
|
static generateValidationErrorMessage(payload: RawObjectDataProcessor.Localization.DataForMessagesBuilding, localization?: RawObjectDataProcessor.Localization): string;
|
|
@@ -24,6 +25,7 @@ declare class RawObjectDataProcessor {
|
|
|
24
25
|
private processPolymorphicValue;
|
|
25
26
|
private get currentObjectPropertyDotSeparatedQualifiedName();
|
|
26
27
|
private registerValidationError;
|
|
28
|
+
private createInitialObjectSnapshotIfNotCreatedYet;
|
|
27
29
|
private handleFailedPreValidationModification;
|
|
28
30
|
private get isValidationOnlyMode();
|
|
29
31
|
private static getNormalizedPreValidationModifications;
|
|
@@ -148,7 +150,7 @@ declare namespace RawObjectDataProcessor {
|
|
|
148
150
|
mustMakeReadonly?: boolean;
|
|
149
151
|
mustLeaveEvenRenamed?: boolean;
|
|
150
152
|
}>;
|
|
151
|
-
type ConditionAssociatedWithProperty = Readonly<{
|
|
153
|
+
export type ConditionAssociatedWithProperty = Readonly<{
|
|
152
154
|
predicate: ConditionAssociatedWithProperty.Predicate;
|
|
153
155
|
descriptionForLogging: string;
|
|
154
156
|
}>;
|
|
@@ -159,10 +161,11 @@ declare namespace RawObjectDataProcessor {
|
|
|
159
161
|
rawData__currentObjectDepth: ArbitraryObject;
|
|
160
162
|
rawData__full: ArbitraryObject;
|
|
161
163
|
targetPropertyDotSeparatedPath: string;
|
|
164
|
+
targetPropertyPathSegments: Array<string | number>;
|
|
162
165
|
}>;
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
|
-
type ConditionAssociatedWithTupleElement = Readonly<{
|
|
168
|
+
export type ConditionAssociatedWithTupleElement = Readonly<{
|
|
166
169
|
predicate: ConditionAssociatedWithTupleElement.Predicate;
|
|
167
170
|
descriptionForLogging: string;
|
|
168
171
|
}>;
|