Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a special case for type Union option with an unknown case #44

Open
NinoFloris opened this issue Jul 30, 2018 · 2 comments
Open

Comments

@NinoFloris
Copy link

NinoFloris commented Jul 30, 2018

I'd like to propose a special case for the type signature where an option wraps a union.

I believe that when external input is not correct (say an unknown case) that if the type is Union option it should be a default or a config option to return None instead of throwing

Currently an unknown case will just throw in the recursive call to the same serializer with
System.Exception: Cannot parse DU field-less value: z. Expected names: x, y

@NinoFloris
Copy link
Author

I'm currently using this as a converter inserted before CompactUnionConverter.

https://gist.github.com/NinoFloris/327c4b4af2c09b159b4af85d58eee4e8

(I have just licensed it under CC0, so it's public domain!)

@blumu
Copy link
Contributor

blumu commented Aug 3, 2018

@NinoFloris Great suggestion. If you could turn your gist into a pull request we could consider integrating in into the official FSharpLu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants