Uncaught Error: Validate values using validator#validate(value, attr) before calling MxObject#set

4
Certain floats/decimals won't save in Mendix 6. Consider the following JS console output when setting a decimal values: > obj.set(this.valueAttr, Math.fround(value / this.calcNumber)); The error I get is: > Uncaught Error: Validate values using validator#validate(value, attr) before calling MxObject#set.(…)set @ mxui.js?636010649656277210:29(anonymous function) @ VM1634:1setDBValue @ widgets/Converter/widget/converter.js:481checkChange @ widgets/Converter/widget/converter.js:455(anonymous function) @ widgets/Converter/widget/converter.js:348(anonymous function) @ mxui.js?636010649656277210:21dispatch @ widgets/Converter/lib/jquery-1.11.2.js:4665elemData.handle @ widgets/Converter/lib/jquery-1.11.2.js:4333 Some debugging values in Console: > value < Big {s: 1, e: -1, c: Array[3]} value.toFixed() < "0.175" value / this.calcNumber < 0.05833333333333333
asked
1 answers
3

The solution incase anybody was wondering, was using Mendix' parsValue function, which returns a Big object. You just need to pass it a string representation of your int value:

big = mx.parser.parseValue(''+intValue)
big.toFixed()

or

big.round(numberOfDecimals)

You don't need to import Big.js explicitly for this workaround

answered