fix(Field): fix the issue of checking empty value (#7050)

* fix(Field): fix the issue of checking empty value

* fix: field tests

* docs: remove radio-group

* docs: remove required translation key
This commit is contained in:
Victor 2020-09-02 20:14:55 +08:00 committed by GitHub
parent 438d34caf1
commit f8d2572354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -190,7 +190,9 @@ export default createComponent({
if (Array.isArray(value)) { if (Array.isArray(value)) {
return !value.length; return !value.length;
} }
if (value === 0) {
return false;
}
return !value; return !value;
}, },

View File

@ -126,10 +126,7 @@ test('use stepper', async () => {
}); });
await submitForm(wrapper); await submitForm(wrapper);
expect(onFailed).toHaveBeenCalledWith({ expect(onFailed).toBeCalledTimes(0);
errors: [{ message: 'foo', name: 'A' }],
values: { A: 0 },
});
wrapper.setData({ value: 1 }); wrapper.setData({ value: 1 });
@ -146,10 +143,7 @@ test('use rate', async () => {
}); });
await submitForm(wrapper); await submitForm(wrapper);
expect(onFailed).toHaveBeenCalledWith({ expect(onFailed).toBeCalledTimes(0);
errors: [{ message: 'foo', name: 'A' }],
values: { A: 0 },
});
wrapper.setData({ value: 1 }); wrapper.setData({ value: 1 });
@ -166,10 +160,7 @@ test('use slider', async () => {
}); });
await submitForm(wrapper); await submitForm(wrapper);
expect(onFailed).toHaveBeenCalledWith({ expect(onFailed).toBeCalledTimes(0);
errors: [{ message: 'foo', name: 'A' }],
values: { A: 0 },
});
wrapper.setData({ value: 50 }); wrapper.setData({ value: 50 });