diff --git a/keywords_object.go b/keywords_object.go index 62ce0de..f4f4d55 100644 --- a/keywords_object.go +++ b/keywords_object.go @@ -325,14 +325,16 @@ func (ap *AdditionalProperties) ValidateKeyword(ctx context.Context, currentStat if currentState.IsLocallyEvaluatedKey(key) { continue } - if ap.schemaType == schemaTypeFalse { - currentState.AddError(data, "additional properties are not allowed") - return - } + currentState.SetEvaluatedKey(key) subState.ClearState() subState.DescendInstanceFromState(currentState, key) + if ap.schemaType == schemaTypeFalse { + subState.AddError(data, "additional properties are not allowed") + return + } + (*Schema)(ap).ValidateKeyword(ctx, subState, obj[key]) currentState.UpdateEvaluatedPropsAndItems(subState) } diff --git a/schema_test.go b/schema_test.go index 1c30604..4defddf 100644 --- a/schema_test.go +++ b/schema_test.go @@ -666,6 +666,18 @@ func TestValidateBytes(t *testing.T) { `/1: false type should be string, got boolean`, `/2: type should be string, got null`, }}, + {`{ + "type": "object", + "properties" : { + }, + "additionalProperties" : false + }`, + `{ + "port": 80 +}`, + []string{ + `/port: {"port":80} additional properties are not allowed`, + }}, } for i, c := range cases {