[4.2] Add public iterate() method to validator

Replaces #5734. The original author remains on the commit.