How do I tell my sails model that I want some specific number decimal places for a type: 'float'
attribute? Like decimalPlaces: 4
or something of that ilk?
The problem is that when i post a value to this entry, the value on disk is truncated to the .00
(hundreds) place. Say I want: 3243.2352362
to be stored just as it is. Currently this is transformed into 3243.24
If it matters I'm using the sails-mysql adapter.
types: {
decimal2: function(number){
return ((number *100)%1 === 0);
}
},
attributes: {
myNumber: {
type: 'float',
decimal2: true
}
}
This is for 2 decimal places though. I cant find a way to make it for dynamically changing N as there is afaik no way to pass a parameter to custom validation.
Workaround for this issue would be to check for custom amount of decimal places in beforeValidation()
function.