MCPcopy
hub / github.com/colinhacks/zod / isValidBase64

Function isValidBase64

packages/zod/src/v4/core/schemas.ts:913–925  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

911
912////////////////////////////// ZodBase64 //////////////////////////////
913export 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
927export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {}
928export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {}

Callers 2

schemas.tsFile · 0.85
isValidBase64URLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected