New Validator rules format + tests. (#5127)

Same as  #5136 but with tests, better empty rules handling, tests and commited to 4.2.
This can be a one liner, like the on you removed.