Effect CommunityEC
Effect Community2y ago
3 replies
tamuccino

Seeking Guidance on Implementing Fallbacks in Effect Schema During Codebase Migration

Hey everyone! I'm in the process of migrating our codebase from io-ts to Effect Schema, and so far, it's been a smooth transition. However, we're running into some issues when dealing with 'fallbacks'. We previously used withFallback from io-ts-types. Could someone help me understand how to achieve similar functionality using Effect Schema? For example, I have a schema that accepts a string and tries to parse it into a Date object. But if the parsing fails, I want it to fallback to returning the original string (i.e., output type would be string | Date). So basically a schema that never fails. Can anyone provide an example or guidance on how to implement this using Effect Schema?
Was this page helpful?