rescript-schema icon indicating copy to clipboard operation
rescript-schema copied to clipboard

`S.float` allows `Infinity` but serialises it to `null`

Open mediremi opened this issue 8 months ago • 3 comments

When serialising Infinity to JSON using S.float, it becomes null. However, this means that when parsing the serialised JSON, sury throws the error Expected number, received null.

I think it'd make sense for S.float to throw an error when given Infinity, just like it does for NaN.

mediremi avatar Jul 04 '25 20:07 mediremi

Makes sense. I'll double check the behavior of other libraries.

DZakh avatar Jul 04 '25 21:07 DZakh

@DZakh Will the PR for this feature be accepted?

arusakov avatar Sep 16 '25 14:09 arusakov

Yes, but I'd say it should use a global flag, just like NaN does. Some thing like safe number check.

DZakh avatar Sep 17 '25 09:09 DZakh