diff --git a/main.html b/main.html
index bd1775b8..d6898f37 100644
--- a/main.html
+++ b/main.html
@@ -31,7 +31,7 @@
Show all rows
Show valid rows
Show invalid rows
- Version 0.4.2
+ Version 0.5.0
diff --git a/main.js b/main.js
index 02a88d3c..064a5e23 100644
--- a/main.js
+++ b/main.js
@@ -594,8 +594,6 @@ const changeRowVisibility = (id, invalidCells, hot) => {
HOT.updateSettings({hiddenRows: {rows: hiddenRows}});
}
-const REGEX_DECIMAL = /^(-|\+|)(0|[1-9]\d*)(\.\d+)?$/
-
/**
* Get a collection of all invalid cells in the grid.
* @param {Object} hot Handsontable instance of grid.
@@ -606,6 +604,9 @@ const REGEX_DECIMAL = /^(-|\+|)(0|[1-9]\d*)(\.\d+)?$/
const getInvalidCells = (hot, data) => {
const invalidCells = {};
const fields = getFields(data);
+
+ const regexDecimal = /^(-|\+|)(0|[1-9]\d*)(\.\d+)?$/;
+
for (let row=0; row {
valid = fields[col].requirement !== 'required';
} else if (datatype === 'xs:nonNegativeInteger') {
const parsedInt = parseInt(cellVal, 10);
- valid =
- !isNaN(cellVal) && parsedInt >= 0 && parsedInt.toString()===cellVal
- && testNumericRange(parsedInt, fields[col])
+ valid = !isNaN(cellVal) && parsedInt>=0
+ valid &= parsedInt.toString()===cellVal;
+ valid &= testNumericRange(parsedInt, fields[col]);
} else if (datatype === 'xs:decimal') {
- // Test against: 10 1 0 0.1 10e2 -1 0.0 0.0.2
const parsedDec = parseFloat(cellVal);
- valid = !isNaN(cellVal) && REGEX_DECIMAL.test(cellVal)
- && testNumericRange(parsedDec, fields[col]);
+ valid = !isNaN(cellVal) && regexDecimal.test(cellVal);
+ valid &= testNumericRange(parsedDec, fields[col]);
} else if (datatype === 'xs:date') {
valid = moment(cellVal, 'YYYY-MM-DD', true).isValid();
} else if (datatype === 'select') {
@@ -648,11 +648,10 @@ const getInvalidCells = (hot, data) => {
/**
* Test a given number against an upper or lower range, if any.
- @param {Number} number to be compared.
- @param {Object} field that contains min and max limits.
- @return {Boolean} validity of field.
- @
-*/
+ * @param {Number} number to be compared.
+ * @param {Object} field that contains min and max limits.
+ * @return {Boolean} validity of field.
+ */
const testNumericRange = (number, field) => {
if (field['xs:minInclusive'] !== '') {