Skip to content

Commit

Permalink
fix: isValidNumber for support zero value in the component numberInput
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey authored and geoffrey committed Jan 31, 2020
1 parent 1d0cc81 commit b62c96e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/Form/Input/number/src/Number.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ describe('Form/NumberInput/Number', () => {
expect(goodNumber).toBe(2.1);
goodNumber = parseValueToNumber('2,20');
expect(goodNumber).toBe(2.2);
goodNumber = parseValueToNumber('0');
expect(goodNumber).toBe(0);
});
});
2 changes: 1 addition & 1 deletion packages/Form/Input/number/src/NumberHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const endWith = (str, suffix) =>
str.indexOf(suffix, str.length - suffix.length) !== -1;

const isValidNumber = value => {
if (!value) {
if (value === null || value === undefined) {
return false;
}
const regex = new RegExp('^\\d+([,.]\\d+)?$', 'gi');
Expand Down

0 comments on commit b62c96e

Please sign in to comment.