You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shouldn't there be a parse function? Given a base64 encoded string from the untyped world out there, do I really need to both check if its encoding is correct and then assert that it is correct? I looked for a function of type a -> Either e (Base64 k a) and a -> Maybe (Base64 k a) but couldn't find anything.
The text was updated successfully, but these errors were encountered:
The problem with base64 is that you can have a string that consists only of valid characters from a particular base64 alphabet, and have it still be structurally incorrect base64, because the bytes are messed up in one way or another. The only real way to know that a string is base64 is to actually decode it and check to see if the value is correct, and produce errors along the way. decodeBase64Untyped and the like are roughly that process, so to parse is to decode and validate whether you have an error. I provide a quick check in the form of isBase64, which produces a Bool, which isn't quite what you want, but the decode step is exactly the shape of what you want:
Otherwise, if you want something that asserts this yourself, i mean, it doesn't quite meet my Fairbarn threshold for writing a new function, since it's special in the sense that it's basically \b -> if isBase64 b then assertBase64 b else "your error" or simply \b -> assertBase64 b <$ decodeBase64Untyped b.
Shouldn't there be a parse function? Given a base64 encoded string from the untyped world out there, do I really need to both check if its encoding is correct and then assert that it is correct? I looked for a function of type
a -> Either e (Base64 k a)
anda -> Maybe (Base64 k a)
but couldn't find anything.The text was updated successfully, but these errors were encountered: