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

Row identifier for CSV errorMappingField #517

Closed
clamothe opened this Issue May 27, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@clamothe
Copy link

clamothe commented May 27, 2018

Is there a way to identify which row a field mapping error occurred for?

I need to display validation errors in my UI if a CSV is not parsable due to field-level errors.
My fallback solution would be to use Strings for every field in my CSV parsing model, as to be permissive, then to validate this object and convert it to a more correctly typed object if validation passes.

That said, it would be great to be able to define the desired types directly on the CSV model (LocalDate, various Enums, etc). If I do so however, I cannot currently catch conversion errors in such a way that both the column and row in error are identified.

Ideally all errors in a particular row would be caught in the first run too, as opposed to short-circuiting parsing of a row once the first field error is encountered. This may be current functionality, I'm not certain.

Thank you!

@arnaudroger

This comment has been minimized.

Copy link
Owner

arnaudroger commented May 27, 2018

Thanks for the idea, I need to think about it. when we parse the csv it does not have the visibility on the full line, but just see cell by cell. Though we could pass a partially constructed object or the list a constructor args currently build - for constructor injected object, as the information is there in the parser.

@clamothe

This comment has been minimized.

Copy link
Author

clamothe commented May 27, 2018

I'm accomplishing validation now by having a very permissive CSV model, with all String fields. It has Hibernate Validator annotations on it. If it passes validation, then I convert it to a different class that has more specific types (i.e. LocalDate instead of String). This solution feels good enough to me.

arnaudroger added a commit that referenced this issue Jun 9, 2018

@arnaudroger

This comment has been minimized.

Copy link
Owner

arnaudroger commented Jun 10, 2018

so I've been thinking about it and I came with that prototype

where basically the mapper will not map to the object directly but to a wrapper that will collect the error that occurs during the parsing.

that would be added to the mapper factory as a one call - name undefined now. but would work as in the test.
@clamothe what do you think?

@arnaudroger arnaudroger added this to the 4.0.0 milestone Jun 13, 2018

arnaudroger added a commit that referenced this issue Jun 14, 2018

arnaudroger added a commit that referenced this issue Jun 14, 2018

arnaudroger added a commit that referenced this issue Jun 14, 2018

arnaudroger added a commit that referenced this issue Jun 14, 2018

@arnaudroger

This comment has been minimized.

Copy link
Owner

arnaudroger commented Jun 14, 2018

will be released part of 4.0.0

@arnaudroger

This comment has been minimized.

Copy link
Owner

arnaudroger commented Aug 15, 2018

@clamothe it's released now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.