@@ -3,8 +3,8 @@ import type { NonBooleanJsfSchema, SchemaValue } from '../types'
33import { isObjectValue } from './util'
44
55// Represents a file-like object, either a browser native File or a plain object.
6- // Both must have name (string) and size (number) properties .
7- export type FileLike = ( File & { name : string , size : number } ) | { name : string , size : number }
6+ // A plain object must have a name (string) property .
7+ export type FileLike = File | { name : string , size ? : number }
88
99/**
1010 * Validates file-specific constraints (maxFileSize, accept).
@@ -48,7 +48,7 @@ export function validateFile(
4848
4949 // 2. Check structure of array items: Each item must be a FileLike object.
5050 const isStructureValid = value . every (
51- file => isObjectValue ( file ) && typeof file . name === 'string' && typeof file . size === 'number' ,
51+ file => isObjectValue ( file ) && ( typeof file . name === 'string' || file instanceof File ) ,
5252 )
5353
5454 if ( ! isStructureValid ) {
@@ -62,7 +62,7 @@ export function validateFile(
6262 if ( typeof presentation ?. maxFileSize === 'number' ) {
6363 const maxSizeInBytes = presentation . maxFileSize * 1024 // Convert KB from schema to Bytes
6464 // Check if *any* file exceeds the limit.
65- const isAnyFileTooLarge = files . some ( file => file . size > maxSizeInBytes )
65+ const isAnyFileTooLarge = files . some ( file => ( file . size ?? 0 ) > maxSizeInBytes )
6666
6767 if ( isAnyFileTooLarge ) {
6868 return [ { path, validation : 'maxFileSize' , schema, value } ]
0 commit comments