Created
July 25, 2016 11:04
-
-
Save simonewebdesign/bd7ea2a67501b29cfb32cc47e91c4375 to your computer and use it in GitHub Desktop.
An example of Json.Decoder (Result a b) in Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decodeSubmittedReportPayload : Json.Decoder SubmittedReportPayload | |
decodeSubmittedReportPayload = | |
Json.object1 | |
SubmittedReportPayload | |
("report" := decodeReportCredentials) | |
decodeInvalidReportPayload : Json.Decoder InvalidReportPayload | |
decodeInvalidReportPayload = | |
Json.object1 | |
InvalidReportPayload | |
("validation_messages" := Json.list decodeValidationMessage) | |
decodeSubmit : Json.Decoder (Result InvalidReportPayload SubmittedReportPayload) | |
decodeSubmit = | |
Json.oneOf | |
[ map Ok decodeSubmittedReportPayload | |
, map Err decodeInvalidReportPayload | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment