Would be cool, if this library supports base64 decode and encode natively.
My scenario: I fetch some base64 encoded Json StringFromBase64.pipe(JsonFromString).
Suggested Solution
I'm new to io-ts, so this might not be the correct way to implement it:
export const StringFromBase64 = new t.Type<string, string, string>(
'StringFromBase64',
(u): u is string => typeof u === 'string',
(s, c) => {
try {
return t.success(atob(s));
} catch (e) {
return t.failure(s, c);
}
},
s => btoa(s)
);
🚀 Feature request
Desired Behavior
Would be cool, if this library supports base64 decode and encode natively. My scenario: I fetch some base64 encoded Json
StringFromBase64.pipe(JsonFromString)
.Suggested Solution
I'm new to io-ts, so this might not be the correct way to implement it: