Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

398
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!