Skip to content

Commit f846e04

Browse files
author
Larry Botha
authored
Merge pull request #117 from tjinauyeung/fix/add-tests-for-isvalid-on-nested-arrays
2 parents 22f948a + 03482d6 commit f846e04

File tree

2 files changed

+132
-69
lines changed

2 files changed

+132
-69
lines changed

lib/util.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {dequal as isEqual} from 'dequal/lite';
22

33
function subscribeOnce(observable) {
4-
return new Promise((resolve) => {
4+
return new Promise(resolve => {
55
observable.subscribe(resolve)(); // immediately invoke to unsubscribe
66
});
77
}
88

99
function update(object, path, value) {
10-
object.update((o) => {
10+
object.update(o => {
1111
set(o, path, value);
1212
return o;
1313
});
@@ -26,11 +26,14 @@ function isEmpty(object) {
2626
}
2727

2828
function getValues(object) {
29-
let result = [];
29+
let results = [];
30+
3031
for (const [, value] of Object.entries(object)) {
31-
result = [...result, ...(typeof value === 'object' ? getValues(value) : [value])];
32+
const values = typeof value === 'object' ? getValues(value) : [value];
33+
results = [...results, ...values];
3234
}
33-
return result;
35+
36+
return results;
3437
}
3538

3639
// TODO: refactor this so as not to rely directly on yup's API
@@ -51,7 +54,7 @@ function getErrorsFromSchema(initialValues, schema, errors = {}) {
5154
case schema[key].type === 'array': {
5255
const values =
5356
initialValues && initialValues[key] ? initialValues[key] : [];
54-
errors[key] = values.map((value) =>
57+
errors[key] = values.map(value =>
5558
getErrorsFromSchema(
5659
value,
5760
schema[key].innerType.fields,
@@ -74,7 +77,7 @@ const deepEqual = isEqual;
7477

7578
function assignDeep(object, value) {
7679
if (Array.isArray(object)) {
77-
return object.map((o) => assignDeep(o, value));
80+
return object.map(o => assignDeep(o, value));
7881
}
7982
const copy = {};
8083
for (const key in object) {

0 commit comments

Comments
 (0)