jazz icon indicating copy to clipboard operation
jazz copied to clipboard

Allow defining default values in CoMaps

Open linear[bot] opened this issue 1 year ago • 1 comments

linear[bot] avatar Aug 04 '24 19:08 linear[bot]

I wonder if encoded could never be optional, and it would require the Encoder itself to accept undefined values (as input) which it'll encode (maybe as undefined too)

co.encoded(Encoders.optional.Date)
// which is basically
co.encoded(Schema.UndefinedOr(Encoders.Date))
  1. The thing is that undefined is not a part of JsonValue so it isn't allowed as an Encoder input or output
  2. [@effect/schema](https://effect-ts.github.io/effect/schema/Schema.ts.html#withdefaults) already allows to have default values upon creation, decoding, or both

Schniz avatar Aug 05 '24 05:08 Schniz