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

Support for isRequired (mandatoriness) check #52

Closed
sachinlala opened this issue Nov 9, 2017 · 2 comments
Closed

Support for isRequired (mandatoriness) check #52

sachinlala opened this issue Nov 9, 2017 · 2 comments

Comments

@sachinlala
Copy link

Background:
We're in need for a fast and feature-rich CSV Parser and have zeroed-in on using jackson-dataformats-text library. We will be passing the 'Schema' object as an input (which is populated from a schema-file we receive from an upstream system). For each field, we will provide a 'Name' and 'Data Type'. Additionally, we would like to provide an input 'isRequired' so if a field is marked isRequired=true but there is no data in that field in the incoming CSV file, we need to raise an exception.

Requirement:
So far, we could not find support for 'isRequired' check. Please can you advise if this is already present or if not, could this be taken as a new requirement to add the feature in an upcoming release ?

Thanks.

@cowtowncoder
Copy link
Member

Required-ness check would have to be added in jackson-databind, as format modules do not have information available. It is a long-standing request:

FasterXML/jackson-databind#230

As things are, checks are only implemented for one special case: Creator properties. So if you define constructor or factory method like:

@JsonCreator
public MyType(@JsonProperty(required=true) String name), ....)

verification is made. Otherwise, if only passing via setters or assigned to fields, no check is made.

Challenge in this case is simply complexity of adding explicit state and tracking for properties; added overhead, and avoiding the overhead if no checks are needed. So it is a large undertaking. Perhaps it could be implemented for 3.0: this is something many users have requested.

@cowtowncoder
Copy link
Member

Since this is covered by issue I linked to, will close this issue: I think support needs to go in databind and not dataformat modules. So closing issue here as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants