@beseif-solutions/prow-core 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -457,7 +457,9 @@ const recursive_schema = async (field, data, options) => {
|
|
|
457
457
|
: newField.key;
|
|
458
458
|
const value = lodash_1.default.get(data, relativeKey, newField.default);
|
|
459
459
|
const resolved = context_1.default.resolve(newField, value, options.context);
|
|
460
|
-
|
|
460
|
+
if (!options.no_undefined || typeof resolved !== `undefined`) {
|
|
461
|
+
lodash_1.default.set(data, relativeKey, resolved);
|
|
462
|
+
}
|
|
461
463
|
if (typeof resolved === `undefined` && options.array) {
|
|
462
464
|
return { schema: null, field: null };
|
|
463
465
|
}
|
|
@@ -483,7 +485,7 @@ const recursive_schema = async (field, data, options) => {
|
|
|
483
485
|
if (noArrayField.type === `dict` && noArrayField.items) {
|
|
484
486
|
const items = [];
|
|
485
487
|
for (const item of noArrayField.items) {
|
|
486
|
-
const recursive = await recursive_schema(item, data, { alter: options.alter && true, relative: `${relativeKey}[0]`, context: options.context });
|
|
488
|
+
const recursive = await recursive_schema(item, data, { alter: options.alter && true, relative: `${relativeKey}[0]`, context: options.context, no_undefined: true });
|
|
487
489
|
if (recursive) {
|
|
488
490
|
items.push({ key: item.key, schema: recursive.schema, field: recursive.field });
|
|
489
491
|
}
|
package/package.json
CHANGED
|
@@ -478,7 +478,7 @@ export const alter = (field: Field, relative: string, data: Record<string, any>)
|
|
|
478
478
|
return cloned;
|
|
479
479
|
};
|
|
480
480
|
|
|
481
|
-
const recursive_schema = async (field: Field, data: Record<string, any>, options: { alter: boolean, relative?: string, array?: boolean,
|
|
481
|
+
const recursive_schema = async (field: Field, data: Record<string, any>, options: { alter: boolean, context: Record<string, any>, relative?: string, array?: boolean, no_undefined?: boolean }): Promise<{ schema: Joi.Schema, field: Field }> => {
|
|
482
482
|
try {
|
|
483
483
|
let newField: Field = _.cloneDeep(field);
|
|
484
484
|
|
|
@@ -507,7 +507,7 @@ const recursive_schema = async (field: Field, data: Record<string, any>, options
|
|
|
507
507
|
|
|
508
508
|
// resolve value with context (even if it's not valid)
|
|
509
509
|
const resolved = context.resolve(newField, value, options.context);
|
|
510
|
-
_.set(data, relativeKey, resolved);
|
|
510
|
+
if (!options.no_undefined || typeof resolved !== `undefined`) { _.set(data, relativeKey, resolved); }
|
|
511
511
|
|
|
512
512
|
// omit undefined for array mappings
|
|
513
513
|
if (typeof resolved === `undefined` && options.array) { return { schema: null, field: null }; }
|
|
@@ -537,7 +537,7 @@ const recursive_schema = async (field: Field, data: Record<string, any>, options
|
|
|
537
537
|
const items: { key: string, schema: Joi.Schema, field: Field }[] = [];
|
|
538
538
|
|
|
539
539
|
for (const item of noArrayField.items) {
|
|
540
|
-
const recursive = await recursive_schema(item, data, { alter: options.alter && true, relative: `${relativeKey}[0]`, context: options.context });
|
|
540
|
+
const recursive = await recursive_schema(item, data, { alter: options.alter && true, relative: `${relativeKey}[0]`, context: options.context, no_undefined: true });
|
|
541
541
|
if (recursive) { items.push({ key: item.key, schema: recursive.schema, field: recursive.field }); }
|
|
542
542
|
}
|
|
543
543
|
|