Effect CommunityEC
Effect Community2y ago
3 replies
adrian_g

Schema for Optional Boolean Property with Default Encoding

Is the currently the most concise way of creating a schema for a boolean property which optional in
Type
, requiaed in Encoded which defaults to
true
when encoding? Thanks!

S.requiredToOptional(
    S.Boolean,
    S.Boolean,
    {
      decode: Option.some,
      encode: Option.getOrElse(() => true),
    },
  )
Was this page helpful?