The value to use if any field is absent
The decoder to run on that field
const decoder = Decode.optionalAt(['outer', 'inner', 'value'], 100, Decode.integer);
decode(decoder, { outer: { inner: { value: 42 } } }) === 42
decode(decoder, { outer: { inner: { } } }) === 100
decode(decoder, { outer: { } }) === 100
decode(decoder, {}) === 100
decode(decoder, 42) // Fails
decode(decoder, { outer: 42 }) // Fails
decode(decoder, { outer: { inner: 42 } }) // Fails
Generated using TypeDoc
This is the same as Decode.at, but implemented in terms of Decode.optionalField instead of Decode.field. This means that the provided value is returned if any object in the given path is missing the next property.