ForbesLindesay / funtypes

Runtime validation for static types
MIT License
29 stars 4 forks source link

ParsedValue in a union does not properly check the underlying type #60

Open swiftvimla opened 1 year ago

swiftvimla commented 1 year ago

Screenshot 2022-10-08 at 01 08 06

I ran this complete example in Quokka to show the output inline.

ForbesLindesay commented 10 months ago

If you want to use the ParsedValue in a union you need to either:

  1. Implement test.
  2. Ensure that serialize returns {success: false, value: ... } when the value is not valid.

We can't test the underlying value first when in serialize mode because we need the serialised value in order to test it against the underlying type.