@@ -87,17 +87,13 @@ const _getColTypeFromTypeArray = (typeArray) => {
8787} ;
8888
8989const _validateFormat = ( rows , hasHeader , cols , options ) => {
90- const colsData = cols . map ( ( col ) => ( {
91- ...col ,
92- type : _getColTypeFromTypeArray ( col . type ) ,
93- } ) ) ;
9490 const errors = [ ] ;
95- const knownColsCount = colsData . length ;
91+ const knownColsCount = cols . length ;
9692 const startIndex = hasHeader ? 1 : 0 ;
9793
98- const colMeta = colsData . map ( ( col ) => ( {
94+ const colMeta = cols . map ( ( col ) => ( {
9995 field : col . field ,
100- type : col . type ,
96+ type : _getColTypeFromTypeArray ( col . type ) ,
10197 acceptsEmptyFields : col . acceptsEmptyFields ?? col . cellEditorParams ?. acceptsEmptyFields ?? false ,
10298 colOptions : {
10399 ...options ,
@@ -119,7 +115,7 @@ const _validateFormat = (rows, hasHeader, cols, options) => {
119115 const row = rows [ rowIndex ] ;
120116 while ( row [ row . length - 1 ] === undefined && row . length > knownColsCount ) row . pop ( ) ;
121117
122- if ( row . length < knownColsCount && ! row . includes ( undefined ) ) {
118+ if ( row . length !== knownColsCount || row . includes ( undefined ) ) {
123119 _forgeColumnsCountError ( row , rowIndex + 1 , cols , errors ) ;
124120 }
125121
@@ -128,8 +124,7 @@ const _validateFormat = (rows, hasHeader, cols, options) => {
128124 const value = row [ colIndex ] ;
129125 if ( value === undefined ) continue ;
130126
131- const typeStr = Array . isArray ( type ) ? type [ 0 ] : type ;
132- const validationResult = ValidationUtils . isValid ( value , typeStr , colOptions , acceptsEmptyFields ) ;
127+ const validationResult = ValidationUtils . isValid ( value , type , colOptions , acceptsEmptyFields ) ;
133128 if ( validationResult !== true ) {
134129 const { summary : errorSummary , context : errorContext } = validationResult ;
135130 const errorLoc = `Line ${ rowIndex + 1 } , Column ${ colIndex + 1 } ("${ field } ")` ;
0 commit comments