Add float (or finite) type #1960
Labels
enhancement
Possible enhancement
has PR
A Pull Request to fix the issue is available
help/PR welcome
Help/Pull request from contributors to fix the issue is welcome
level: easy
Discussed in #1959
Originally posted by davetapley September 15, 2022
Since we already have an
integer
type:mobx-state-tree/packages/mobx-state-tree/src/types/primitives.ts
Lines 113 to 117 in 6a50d79
Do we want one or both of these?
float
type, which would restrict againstNaN
.finite
type, which would restrict againstNaN
and infinities (taking inspiration fromisFinite
).I'll concede that both could be implemented with
refinement
, but so couldinteger
and we already have that.This would have saved me from a bug where I am using
parseFloat
and aNaN
was sneaking in to my model.It would be great if I could just specify
float
in my model and have MST throw, instead of having to check forNaN
manually.Happy to make a PR if it will be accepted 🤞🏻
The text was updated successfully, but these errors were encountered: