Skip to content

Commit

Permalink
fix(form): Improve form error handling
Browse files Browse the repository at this point in the history
* 自定义组件 Array 的元素可能为 null

* 自定义组件时没有抛出错误
  • Loading branch information
Liu-Ya committed Apr 12, 2021
1 parent 663d13a commit 9a21b8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/Form/src/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ export function useFormEvents({
const values = await validate();
const res = handleFormValues(values);
emit('submit', res);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/src/hooks/useFormValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function useFormValues({
if (isObject(value)) {
value = transformDateFunc(value);
}
if (isArray(value) && value[0]._isAMomentObject && value[1]._isAMomentObject) {
if (isArray(value) && value[0]?._isAMomentObject && value[1]?._isAMomentObject) {
value = value.map((item) => transformDateFunc(item));
}
// Remove spaces
Expand Down

0 comments on commit 9a21b8b

Please sign in to comment.