Skip to content

Commit

Permalink
fix(form): when model.xxx is undefined, validator will use null
Browse files Browse the repository at this point in the history
… as validation value, closes #2486
  • Loading branch information
07akioni committed Feb 21, 2022
1 parent febba6e commit f97b750
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix `n-data-table` cannot click selection checkbox if the selection column is a column's child.
- Fix `n-table`'s `border-color` abnormal style when this added dynamically, closes [#2403](https://github.com/TuSimple/naive-ui/issues/2403).
- Fix `n-tree`'s `default-expand-all` prop doesn't work for dynamic data.
- Fix `n-form` when `model.xxx` is `undefined`, validator will use `null` as validation value, closes [#2486](https://github.com/TuSimple/naive-ui/issues/2486).

### Feats

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- 修复 `n-data-table` 当 selection column 为某个 column 的子 column 时无法点击全选复选框
- 修复 `n-table` 动态增加时 `border-color` 的样式异常,关闭 [#2403](https://github.com/TuSimple/naive-ui/issues/2403)
- 修复 `n-tree``default-expand-all` 对于动态数据不生效
- 修复 `n-form``model.xxx``undefined` 的时候会使用 `null` 作为验证值,关闭 [#2486](https://github.com/TuSimple/naive-ui/issues/2486)

### Feats

Expand Down
3 changes: 1 addition & 2 deletions src/form/src/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ export default defineComponent({
if (!options.first) options.first = props.first
}
const { value: rules } = mergedRulesRef
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const value = NForm ? get(NForm.props.model, path!, null) : undefined
const value = NForm ? get(NForm.props.model, path || '') : undefined
const activeRules = (
!trigger
? rules
Expand Down

0 comments on commit f97b750

Please sign in to comment.