[#1188] Fix visibility validator

Only the 2.1.x relevant bits were cherry-picked