@@ -30,9 +30,11 @@ public class PropertiesValidator extends BaseJsonValidator implements JsonValida
3030 private static final Logger logger = LoggerFactory .getLogger (PropertiesValidator .class );
3131 private Map <String , JsonSchema > schemas ;
3232 private WalkListenerRunner propertyWalkListenerRunner ;
33+ private ValidationContext validationContext ;
3334
3435 public PropertiesValidator (String schemaPath , JsonNode schemaNode , JsonSchema parentSchema , ValidationContext validationContext ) {
3536 super (schemaPath , schemaNode , parentSchema , ValidatorTypeCode .PROPERTIES , validationContext );
37+ this .validationContext = validationContext ;
3638 schemas = new HashMap <String , JsonSchema >();
3739 for (Iterator <String > it = schemaNode .fieldNames (); it .hasNext (); ) {
3840 String pname = it .next ();
@@ -110,17 +112,19 @@ public Set<ValidationMessage> walk(JsonNode node, JsonNode rootNode, String at,
110112 boolean executeWalk = true ;
111113 for (Map .Entry <String , JsonSchema > entry : schemas .entrySet ()) {
112114 JsonSchema propertySchema = entry .getValue ();
113- JsonNode propertyNode = node .get (entry .getKey ());
115+ JsonNode propertyNode = ( node == null ? null : node .get (entry .getKey () ));
114116 executeWalk = propertyWalkListenerRunner .runPreWalkListeners (ValidatorTypeCode .PROPERTIES .getValue (),
115117 propertyNode , rootNode , at + "." + entry .getKey (), propertySchema .getSchemaPath (),
116- propertySchema .getSchemaNode (), propertySchema .getParentSchema ());
117- if (propertyNode != null && executeWalk ) {
118+ propertySchema .getSchemaNode (), propertySchema .getParentSchema (),
119+ validationContext .getJsonSchemaFactory ());
120+ if (executeWalk ) {
118121 validationMessages .addAll (propertySchema .walk (propertyNode , rootNode , at + "." + entry .getKey (),
119122 shouldValidateSchema ));
120123 }
121124 propertyWalkListenerRunner .runPostWalkListeners (ValidatorTypeCode .PROPERTIES .getValue (), propertyNode ,
122125 rootNode , at + "." + entry .getKey (), propertySchema .getSchemaPath (),
123- propertySchema .getSchemaNode (), propertySchema .getParentSchema (), validationMessages );
126+ propertySchema .getSchemaNode (), propertySchema .getParentSchema (),
127+ validationContext .getJsonSchemaFactory (), validationMessages );
124128 }
125129 }
126130 return validationMessages ;
0 commit comments