mattjbray / ocaml-decoders

Elm-inspired decoders for Ocaml
https://mattjbray.github.io/ocaml-decoders/
Other
84 stars 8 forks source link

Add field_opt for non-present fields with propagated decode errors #5

Closed actionshrimp closed 5 years ago

actionshrimp commented 5 years ago

Adds field_opt, which allows a field to be missing, or expects the decode to succeed if present. This is different from maybe (field .. which allows the decode to fail and still returns None, which makes it hard to distinguish between the field actually not being sent, and decode failure.