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

@JSONProperty not read in ConstraintViolationProblem #610

Closed
PraveenGNair opened this issue Mar 25, 2021 · 2 comments
Closed

@JSONProperty not read in ConstraintViolationProblem #610

PraveenGNair opened this issue Mar 25, 2021 · 2 comments
Labels

Comments

@PraveenGNair
Copy link

PraveenGNair commented Mar 25, 2021

I am using problem-spring-web and my contraint violations are not picking the fieldnames defined in @JsonProperty rather it is picking the deafult field name.

import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;

@NotNull
@JsonProperty(destination_filename)
private String destinationFilename;

And I am getting an error as below when passing empty string through API.

{
  "type": "https://zalando.github.io/problem/constraint-violation",
  "status": 400,
  "violations": [
    {
      "field": "destinationFilename",
      "message": "must not be null"
    }
  ],
  "title": "Constraint Violation"
}

@whiskeysierra Is this a known issue ? or any worksarounds to pick the JSONProperty name in exception fieldname.

@whiskeysierra
Copy link
Collaborator

Fieldnames are provided by your bean validator (probably Hibernate). They can't be controlled via Jackson annotations.

@PraveenGNair
Copy link
Author

Thanks. Though I got it working by overriding createviolation method of ValidationAdviceTrait.

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

No branches or pull requests

2 participants