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

Ability to require specified CSV columns #518

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

Comments

Projects
None yet
2 participants
@clamothe

clamothe commented May 27, 2018

It would be nice to be able to validate that all expected columns are present in the CSV.

ignorePropertyNotFound fulfills my desire to allow the CSV to contain additional unspecified columns. However, there is no MapperBuilderErrorHandler method called if a defined column is actually missing from the CSV.

I've tried adding all required headers using CsvMapperFactory.addKeys.

@arnaudroger

This comment has been minimized.

Show comment
Hide comment
@arnaudroger

arnaudroger May 27, 2018

Owner

keys are there for join, the mapper does not require anything to be present at the minute.
it should be might be possible to had a flag on the property to say it's mandatory and fail to build the mapper if that the case. that would look like that.
but the problem is that column name don't have to match exactly the prop name
anyway i'll looked into it.
prob something like

CsvMapperFactory.newInstance().addColumnProperty("foo", MandatoryProperty.INSTANCE);
Owner

arnaudroger commented May 27, 2018

keys are there for join, the mapper does not require anything to be present at the minute.
it should be might be possible to had a flag on the property to say it's mandatory and fail to build the mapper if that the case. that would look like that.
but the problem is that column name don't have to match exactly the prop name
anyway i'll looked into it.
prob something like

CsvMapperFactory.newInstance().addColumnProperty("foo", MandatoryProperty.INSTANCE);
@clamothe

This comment has been minimized.

Show comment
Hide comment
@clamothe

clamothe May 27, 2018

Thanks for your reply. It's worth noting that I have solved this by adding @NotNull annotations to each of my fields, then running Hibernate Validator.

clamothe commented May 27, 2018

Thanks for your reply. It's worth noting that I have solved this by adding @NotNull annotations to each of my fields, then running Hibernate Validator.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment