Effect CommunityEC
Effect Community16mo ago
2 replies
Josh

Handling Invalid Literal Values in Optional Fields within Structs

If you have const MyLiteral = Schema.Literal('foo', 'bar') is there a way to have that field as part of a larger struct as Option<MyLiteral> so that if the value comes through as baz it'll be a Option.None? Could maybe do it with optionalToOptional/requiredToOptional and do a decodeUnknownOption? but wondering if there's a better way to express that without the nested decoding
Was this page helpful?