(data: string)
| 911 | |
| 912 | ////////////////////////////// ZodBase64 ////////////////////////////// |
| 913 | export function isValidBase64(data: string): boolean { |
| 914 | if (data === "") return true; |
| 915 | // atob ignores whitespace, so reject it up front. |
| 916 | if (/\s/.test(data)) return false; |
| 917 | if (data.length % 4 !== 0) return false; |
| 918 | try { |
| 919 | // @ts-ignore |
| 920 | atob(data); |
| 921 | return true; |
| 922 | } catch { |
| 923 | return false; |
| 924 | } |
| 925 | } |
| 926 | |
| 927 | export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {} |
| 928 | export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {} |
no outgoing calls
no test coverage detected