I am having a string like ,
name = " {
"Name" : "MyName"
}"
and having a Model class like ,
@Valid
Class Model {
@JsonProperty("Name")
@Size(min = 1)
@NotNull
private String name;
}
Now I am converting the string to Java Object by following code,
Model name = objectMapper.readValue(name, Model.class);
So the validation(min = 1 and not null) is not happening with this. How can I validate when I am converting a string to java object?
i will try to help u.
I have an idea and it´s that u divide the process in 2 parts:
First, u take the json and put in on a JSONObject:
Then, u can call, for example, a function passing a json that validate the values of json an if is correct return a model object:
This check if the field "Name" exists and it´s not null.
I don´t know if it is what u want.
I hope it help u.