Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

399
Vistas
Property 'validateFile' does not exist on type 'FileReader'

I have a csv file which I need to validate. here is the function:

 let reader = new FileReader();
  reader.onload = function (e) {
      let resultFile = e.target.result
      let value = this.validateFile((<String>resultFile).split('\n'))
      if (value != "valid") {
        errors += value;
        return errors;
      }
  }

I need to do some validation inside the function validateFile.

validateFile(data) {
     if ((fileLength <= batchProp.MAX_SUBREQUESTS_WITH_OFFERS && this.includeOffers) || (fileLength <= batchProp.MAX_SUBREQUESTS_WITHOUT_OFFERS && !this.includeOffers)) {
  if (!this.checkUploadedFile(data, fileLength)) {
    this.lastRowWasValid = true;
    }
  }
}

But I keep getting this error:

Property 'validateFile' does not exist on type 'FileReader'.

Please suggest how to fix this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use a arrow function to access the global scope which has the validateFile function

let reader = new FileReader();
  reader.onload = function (e) => {
      let resultFile = e.target.result
      let value = this.validateFile((<String>resultFile).split('\n'))
      if (value != "valid") {
        errors += value;
        return errors;
      }
  }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda