@@ -435,23 +435,32 @@ def unevaluatedItems(validator, unevaluatedItems, instance, schema):
435435def unevaluatedProperties (validator , unevaluatedProperties , instance , schema ):
436436 if not validator .is_type (instance , "object" ):
437437 return
438- evaluated_property_keys = find_evaluated_property_keys_by_schema (
438+ evaluated_keys = find_evaluated_property_keys_by_schema (
439439 validator , instance , schema ,
440440 )
441- unevaluated_property_keys = []
441+ unevaluated_keys = []
442442 for property in instance :
443- if property not in evaluated_property_keys :
443+ if property not in evaluated_keys :
444444 for _ in validator .descend (
445445 instance [property ],
446446 unevaluatedProperties ,
447447 path = property ,
448448 schema_path = property ,
449449 ):
450- unevaluated_property_keys .append (property )
451-
452- if unevaluated_property_keys :
453- error = "Unevaluated properties are not allowed (%s %s unexpected)"
454- yield ValidationError (error % extras_msg (unevaluated_property_keys ))
450+ # FIXME: Include context for each unevaluated property
451+ # indicating why it's invalid under the subschema.
452+ unevaluated_keys .append (property )
453+
454+ if unevaluated_keys :
455+ if unevaluatedProperties is False :
456+ error = "Unevaluated properties are not allowed (%s %s unexpected)"
457+ yield ValidationError (error % extras_msg (unevaluated_keys ))
458+ else :
459+ error = (
460+ "Unevaluated properties are not valid under "
461+ "the given schema (%s %s unevaluated and invalid)"
462+ )
463+ yield ValidationError (error % extras_msg (unevaluated_keys ))
455464
456465
457466def prefixItems (validator , prefixItems , instance , schema ):
0 commit comments