Fix detection of unsupported fields with validate API

The validate API was failing to reject JSON input that had unsupported fields placed after a supported field. This was causing invalid requests to be reported as valid.

First commit adds a test that triggers the issue. Second commit fixes it.

Ref. #5685