Effect CommunityEC
Effect Community•2y ago•
3 replies
Liam Butler-Lawrence

Handling Optional Fields in JSON Schema with `S.UndefinedOr` and `S.OptionFromUndefinedOr`

New Schema -> JSON Schema issue 😅

So in our codebase, we take advantage of JSON.parse/stringify's behavior around undefined and define all optional fields in our models as S.UndefinedOr or S.OptionFromUndefinedOr instead of using S.optional. This makes all our code more explicit, among other benefits.

However, I haven't been able to figure out how to get S.UndefinedOr and S.OptionFromUndefinedOr to behave the same as S.optional when using JSONSchema.make
Was this page helpful?