Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last required header is skipped by validation #111

Closed
Rizvanchos opened this issue Jan 13, 2023 · 2 comments
Closed

Last required header is skipped by validation #111

Rizvanchos opened this issue Jan 13, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Rizvanchos
Copy link

Validation doesn't work correctly for the following case:

Steps to reproduce:

  1. CSV file should contain the following headers: "Name,Surname,Age"
  2. Prepare file with content "Name,Surname"
  3. Validation CSV

Actual result:
No validation errors

Expected result:
Validation error that "Age" header is missing

Please note that the validation will work correctly for the headers with the comma: "Name,Surname,"

Dev notes:
It seems this is because of the row.forEach cycle. Without the comma, the array will contain 2 entries (headers config contains 3 entries), but because of the process is based on row entries instead of headers config, it will never check for the absence of the required headers.

image

@shystruk
Copy link
Owner

@Rizvanchos please share a .csv file

@shystruk shystruk added the bug Something isn't working label Jan 18, 2023
@Rizvanchos
Copy link
Author

@shystruk , thanks for the reply! Here is the sample CSV
students.csv

We need to show an error message when headers are invalid and this is the case when the last header is completely absent.
It will work with the current code in the case in the end there is a comma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants