Closed linghengqian closed 10 months ago
Correct: @JsonProperty(required=true)
is only enforced if and when properties are passed via Creator method (constructor or static factory method). It would be nice to support if for Setter/Field injected properties too; it is one of "most-wanted" issues:
https://github.com/FasterXML/jackson-databind/issues/230
Closing this as duplicate (also note: this is not XML-specific issue but same for all backends).
We appreciate issues as very valuable contributions, but just to make sure here are things that are important to do before filing an issue:
TL;
While investigating https://github.com/apache/shardingsphere/pull/29384 , I noticed that without setting
@JsonCreator
for the POJO, therequired
attribute in@JsonProperty
is not checked.I created a minimal unit test at https://github.com/linghengqian/jackson-xml-required-check-test . The core code looks like this.
assertThrows(MismatchedInputException.class, () -> XML_MAPPER.readValue("<TR></TR>", TestRecordWithoutCreator.class));
will not throw any exception.