dynamodb-toolbox
dynamodb-toolbox copied to clipboard
Strings containing floats ending in trailing zeros are unable to be coerced to floats.
Bug Report
Strings containing floats ending in trailing zeros are unable to be coerced to floats.
Instead a 'attr' must be of type number
error is raised.
For example
validateTypes(DocumentClient)({ type: 'number' },'attr', '1.00')
This issue stems from the fact that parseFloat
strips trailing zeros so the string representation ('1.00'
) not longer matches the parseFloat
representaton ('1'
) causing the error to be thrown.
https://github.com/jeremydaly/dynamodb-toolbox/blob/4cbb92a89e156cd7524dae36d1921ea6f7f02503/lib/validateTypes.js#L31
would this be an ok change for this? if so I'll make it and submit a PR..
value == value/1
this works for things I've tried.. "1" == "1"/1 and "1.00" == "1.00"/1 will both return true.. "abdhd1.00" == "abdhd1.00"/1 will return false. null == null/1 will return false as well..
@gpinkham true == true/1
so this is not good enough.