Module for Decoders that always return a valid value.
Phantom type to indicate that a Decoder has defaults provided for all of it's fields.
Phantom type to indicate that a Decoder has a risk in it's procedure thus
rendering the entire decoder susceptible to failure.
A record that carries both:
A. a properly decoded value & [] like { value = "Stuff", errors = [] } or
B. a default value & List Error like { value = "", [Decode.Failure "unexpected null value"] }
Attempt to decode with a decoder that could potentially fail
Provided with defaults using the primitives defined in this module decode will return a value composed of decoded values & defaults paired with whatever associated errors may have happened along the way.
In case you need a tuple instead of record accessors :man_shrugging:
Convert a Validated decoder into a regular elm/json Decoder
Provide a default value, turning a Decoder that has the potential to fail due to missing fields or bad data or, into a Decoder that will always succeed.
wrap a value in a Decoder
turn a regular decoder into a Validated decoder using Maybe & Nothing as the default.
Decoder for a unit value, may be useful when responding to
DELETE requests that return HTTP 201 No Content
Decoder between a JSON boolean and an Elm Bool
Decoder between a JSON number and an Elm Int
Decoder between a JSON number and an Elm Float
Decoder between a JSON string of length 1 and an Elm Char
Decoder between a JSON string and an Elm String
Decoder between a JSON array and an Elm List.
Use when a default for the elements is available to fill if decoding fails. Will still collect errors for the failed decoders
Swallows errors for elements but probably what you want for most use cases...
Decoder between a JSON array and an Elm Array.
Decoder between a JSON object and an Elm Dict.
Datum between a JSON array of length 2 and an Elm Tuple.
Datum between a JSON array of length 3 and an Elm triple.
Specify the name, and a Decoder for a field.
required propagates errors when the name is missing in the resulting json.
optional only propagates errors where the decoder doesn't match the expected type.
andMap for a Decoder WithDefaults
andMap for adding a call to risk
By introducing a raw elm/json decoder you're exposing the rest of your decoder to the possibility of failing
Provide a list of regular elm/json decoders and if all of them fail, provide a default.
Specify that a decoder should use it's defaults when encountering a null
For dealing with a json string inside a json payload.
Tests