Improve filter error messages
jessekelly881 opened this issue · comments
What is the problem this feature would solve?
Currently, the error messages for filters look like "Expected x, actual ${JSON.stringify(val)}"
. For example, in the case of BigDecimal it looks like
"Expected a BigDecimal between -1 and 1, actual {"_id":"BigDecimal","value":"2","scale":0}"
What is the feature you are proposing to solve the problem?
It would be better if the message could use the Pretty instance for the already tested for type when a filter fails. In this case, the preferred message would be:
"Expected a BigDecimal between -1 and 1, actual BigDecimal(2)"
I'm not sure what the best implementation would be in this case though.
What alternatives have you considered?
No response
@jessekelly881 we could detect data types with a custom toString
implementation and use that instead of JSON.stringify
#603
This looks awesome! Thanks @gcanti