Skip to content

Commit

Permalink
Merge pull request #126 from DimitrisRK/custom-validation-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
larrybotha authored Jul 25, 2021
2 parents b5d030f + 0775e9d commit 8122a2d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 20,903 deletions.
2 changes: 1 addition & 1 deletion lib/create-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const createForm = (config) => {
return Promise.resolve()
.then(() => validateFunction(values))
.then((error) => {
if (util.isEmpty(error)) {
if (util.isNullish(error) || util.getValues(error).length === 0) {
clearErrorsAndSubmit(values);
} else {
errors.set(error);
Expand Down
8 changes: 4 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {dequal as isEqual} from 'dequal/lite';

function subscribeOnce(observable) {
return new Promise(resolve => {
return new Promise((resolve) => {
observable.subscribe(resolve)(); // immediately invoke to unsubscribe
});
}

function update(object, path, value) {
object.update(o => {
object.update((o) => {
set(o, path, value);
return o;
});
Expand Down Expand Up @@ -54,7 +54,7 @@ function getErrorsFromSchema(initialValues, schema, errors = {}) {
case schema[key].type === 'array': {
const values =
initialValues && initialValues[key] ? initialValues[key] : [];
errors[key] = values.map(value =>
errors[key] = values.map((value) =>
getErrorsFromSchema(
value,
schema[key].innerType.fields,
Expand All @@ -77,7 +77,7 @@ const deepEqual = isEqual;

function assignDeep(object, value) {
if (Array.isArray(object)) {
return object.map(o => assignDeep(o, value));
return object.map((o) => assignDeep(o, value));
}
const copy = {};
for (const key in object) {
Expand Down
Loading

0 comments on commit 8122a2d

Please sign in to comment.