@@ -35,11 +35,14 @@ export function zodFile(options: ZodFileOptions): z.ZodType<ZodFile> {
3535. any ( )
3636. refine (
3737( file ) :file isFile | Blob | Buffer =>
38- file instanceof File || file instanceof Blob || Buffer . isBuffer ( file ) ,
38+ ( typeof File !== 'undefined' && file instanceof File ) ||
39+ ( typeof Blob !== 'undefined' && file instanceof Blob ) ||
40+ ( typeof Buffer !== 'undefined' && Buffer . isBuffer ( file ) ) ,
41+
3942{ message :'Invalid file provided.' }
4043)
4144. transform ( ( file ) => {
42- if ( file instanceof File ) {
45+ if ( typeof File !== 'undefined' && file instanceof File ) {
4346return {
4447_type :'ZodFile/File' as const ,
4548lastModified :file . lastModified ,
@@ -51,7 +54,7 @@ export function zodFile(options: ZodFileOptions): z.ZodType<ZodFile> {
5154text :( ) => file . text ( ) ,
5255} ;
5356}
54- if ( file instanceof Blob ) {
57+ if ( typeof Blob !== 'undefined' && file instanceof Blob ) {
5558return {
5659_type :'ZodFile/Blob' as const ,
5760lastModified :0 ,
@@ -65,7 +68,7 @@ export function zodFile(options: ZodFileOptions): z.ZodType<ZodFile> {
6568text :( ) => file . text ( ) ,
6669} ;
6770}
68- if ( Buffer . isBuffer ( file ) ) {
71+ if ( typeof Buffer !== 'undefined' && Buffer . isBuffer ( file ) ) {
6972return {
7073_type :'ZodFile/Buffer' as const ,
7174lastModified :0 ,
@@ -79,6 +82,7 @@ export function zodFile(options: ZodFileOptions): z.ZodType<ZodFile> {
7982text :( ) => Promise . resolve ( file . toString ( ) ) ,
8083} ;
8184}
85+
8286throw new Error ( 'Unexpected file type' ) ;
8387} )
8488. refine (