Skip to content

Commit

Permalink
Invalidate negative numbers (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansg44 authored Jun 8, 2020
1 parent e19a4f6 commit 83141e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,11 @@ const getInvalidCells = (hot, data) => {
valid = fields[col].requirement !== 'required';
} else if (datatype === 'integer') {
// https://stackoverflow.com/a/16799538/11472358
valid = !isNaN(cellVal) && parseInt(cellVal, 10).toString()===cellVal;
const parsedInt = parseInt(cellVal, 10);
valid =
!isNaN(cellVal) && parsedInt>=0 && parsedInt.toString()===cellVal;
} else if (datatype === 'decimal') {
valid = !isNaN(cellVal);
valid = !isNaN(cellVal) && parseFloat(cellVal)>=0;
} else if (datatype === 'date') {
valid = moment(cellVal, 'YYYY-MM-DD', true).isValid();
} else if (datatype === 'select') {
Expand Down

0 comments on commit 83141e0

Please sign in to comment.