Merge branch '1.2.x'
This commit is contained in:
@@ -86,7 +86,7 @@ class JsonContentHandler implements ContentHandler {
|
||||
}
|
||||
ExtractedField extracted = this.fieldProcessor.extract(candidate.getPath(),
|
||||
payload);
|
||||
return isEmptyCollection(extracted.getValue());
|
||||
return extracted.getValue() == null || isEmptyCollection(extracted.getValue());
|
||||
}
|
||||
|
||||
private boolean isEmptyCollection(Object value) {
|
||||
|
||||
@@ -183,4 +183,13 @@ public class JsonContentHandlerTests {
|
||||
assertThat(missingFields.get(0).getPath()).isEqualTo("a.[].b.[].c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void describedMissingFieldThatIsChildOfOptionalObjectThatIsNullIsNotConsideredMissing() {
|
||||
List<FieldDescriptor> missingFields = new JsonContentHandler(
|
||||
"{\"a\":null}".getBytes()).findMissingFields(
|
||||
Arrays.asList(new FieldDescriptor("a").optional(),
|
||||
new FieldDescriptor("a.b")));
|
||||
assertThat(missingFields.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user