formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

Number component not working for long values

Open gyanendrasinghpanwar opened this issue 1 year ago • 3 comments

I presume this due to below function in Number.js where we have used parseInt.

parseNumber(value) { // Remove delimiters and convert decimal separator to dot. value = value.split(this.delimiter).join('').replace(this.decimalSeparator, '.');

if (this.component.validate && this.component.validate.integer) {
  return parseInt(value, 10);
}
else {
  return parseFloat(value);
}

}

gyanendrasinghpanwar avatar Jan 08 '24 09:01 gyanendrasinghpanwar

I believe this has more to do with JavaScript limitations rather than this library limitations. Do you have an example number that causes failures?

travist avatar Jan 10 '24 15:01 travist

I believe this has more to do with JavaScript limitations rather than this library limitations. Do you have an example number that causes failures?

"Indeed, this is more with JavaScript limitation. Currently, the number component is working accurately with up to 15 digits; after that, there is data loss due to parseFloat."

Do we have any plans to provide BigInt support in the number component or to offer number validation in the textfield component so that it can be used from there?

Let me know if need any Pull request.

gyanendrasinghpanwar avatar Jan 11 '24 16:01 gyanendrasinghpanwar

hello i used this work around on the calculated Value logic const inputValue=data['test']; if ((inputValue.length>15)) { value=parseFloat(inputValue.replace(".","").substring(0,15)); }

youcefelwaer avatar May 06 '24 10:05 youcefelwaer