Skip to content

Commit 1a5bfee

Browse files
Merge pull request dschnelldavis#194 from rhalff/master
fix never called errors
2 parents 2ce2141 + 77be9fb commit 1a5bfee

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/lib/src/shared/convert-schema-to-draft6.function.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as _ from 'lodash';
2+
13
/**
24
* 'convertSchemaToDraft6' function
35
*
@@ -311,13 +313,7 @@ export function convertSchemaToDraft6(schema, options: OptionObject = {}) {
311313
) {
312314
newSchema[key] = convertSchemaToDraft6(newSchema[key], { changed, draft });
313315
} else {
314-
const clone = object => typeof clone !== 'object' ? object :
315-
typeof object.map === 'function' ?
316-
[ ...object.map(item => clone(item)) ] :
317-
Object.keys(object).reduce((objClone, objKey) =>
318-
Object.assign(objClone, { [objKey]: clone(object[objKey]) }), {}
319-
);
320-
newSchema[key] = clone(newSchema[key]);
316+
newSchema[key] = _.cloneDeep(newSchema[key]);
321317
}
322318
});
323319

src/lib/src/shared/utility.functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function forEachCopy(
128128
errors = false
129129
): any {
130130
if (!hasValue(object)) { return; }
131-
if ((isObject(object) || isArray(object)) && typeof fn !== 'function') {
131+
if ((isObject(object) || isArray(object)) && typeof object !== 'function') {
132132
let newObject: any = isArray(object) ? [] : {};
133133
for (let key of Object.keys(object)) {
134134
newObject[key] = fn(object[key], key, object);

0 commit comments

Comments
 (0)