@@ -87,14 +87,17 @@ const _getColTypeFromTypeArray = (typeArray) => {
8787} ;
8888
8989const _validateFormat = ( rows , hasHeader , cols , options ) => {
90- const colsData = cols . map ( ( col ) => ( { ...col , type : _getColTypeFromTypeArray ( col . type ) } ) ) ;
90+ const colsData = cols . map ( ( col ) => ( {
91+ ...col ,
92+ type : _getColTypeFromTypeArray ( col . type ) ,
93+ } ) ) ;
9194 const errors = [ ] ;
9295 const knownColsCount = colsData . length ;
9396 const startIndex = hasHeader ? 1 : 0 ;
9497
95- const colMeta = cols . map ( ( col ) => ( {
98+ const colMeta = colsData . map ( ( col ) => ( {
9699 field : col . field ,
97- type : _getColTypeFromTypeArray ( col . type ) ,
100+ type : col . type ,
98101 acceptsEmptyFields : col . acceptsEmptyFields ?? col . cellEditorParams ?. acceptsEmptyFields ?? false ,
99102 colOptions : {
100103 ...options ,
@@ -115,17 +118,18 @@ const _validateFormat = (rows, hasHeader, cols, options) => {
115118 for ( let rowIndex = startIndex ; rowIndex < rows . length ; rowIndex ++ ) {
116119 const row = rows [ rowIndex ] ;
117120 while ( row [ row . length - 1 ] === undefined && row . length > knownColsCount ) row . pop ( ) ;
118- if ( row . length !== knownColsCount || row . includes ( undefined ) ) {
121+
122+ if ( row . length < knownColsCount && ! row . includes ( undefined ) ) {
119123 _forgeColumnsCountError ( row , rowIndex + 1 , cols , errors ) ;
120- continue ;
121124 }
122125
123126 for ( let colIndex = 0 ; colIndex < knownColsCount ; colIndex ++ ) {
124127 const { type, colOptions, acceptsEmptyFields, field } = colMeta [ colIndex ] ;
125128 const value = row [ colIndex ] ;
126129 if ( value === undefined ) continue ;
127130
128- const validationResult = ValidationUtils . isValid ( value , type , colOptions , acceptsEmptyFields ) ;
131+ const typeStr = Array . isArray ( type ) ? type [ 0 ] : type ;
132+ const validationResult = ValidationUtils . isValid ( value , typeStr , colOptions , acceptsEmptyFields ) ;
129133 if ( validationResult !== true ) {
130134 const { summary : errorSummary , context : errorContext } = validationResult ;
131135 const errorLoc = `Line ${ rowIndex + 1 } , Column ${ colIndex + 1 } ("${ field } ")` ;
0 commit comments