Answer the question
In order to leave comments, you need to log in
How to make Jackson throw an exception for variables with no value?
Hello,
there is a pojo object:
public class Comment {
private int id; // переменная без заданного значения
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Answer the question
In order to leave comments, you need to log in
Such things are validated somewhere outside. In the case of Spring, you can use validators in controllers.
You can write your own serialization / deserialization for your object, and there you can already fall as you want.
Jackson just serializes/deserializes but doesn't validate them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question