Boolean decoder
Date decoder.
Date decoder expects a value that is a number or a string. It will then try to construct a JavaScript date object from the value.
Number decoder
String decoder
Converts a JSON object to a Map<string, A>.
I would reccomend using this as a decoder of last resort. For correctness, you are probably better off using field decoders and explicitly declaring the shape of the objects you are expecting.
The internal decoder to be applied to the object values
Returns a decoder that always fails, returning an Err with the message passed in.
Converts a JSON object to an array of key value pairs ((string, A)[]). The passed in decoder is applied to the object value. The key will always be converted to a string.
The internal decoder to be applied to the object values
Decodes possibly null or undefined values into types.
There is overlap between nullable
and maybe
decoders.
The difference is that maybe
will always succeed, even if
there is an error in the decoder.
Maybe example:
maybe(string).decodeAny('foo') // => Ok('foo')
maybe(string).decodeAny(null) // => Ok(Nothing)
maybe(string).decodeAny(42) // => Ok(Nothing)
Nullable example:
nullable(string).decodeAny('foo') // => Ok('foo')
nullable(string).decodeAny(null) // => Ok(Nothing)
nullable(string).decodeAny(42) // => Err...
Returns a decoder that always succeeds, resolving to the value passed in.
Generated using TypeDoc
A decoder function takes an object of any type and returns a Result