Add checkings for ANY_*_ID 3178

Addressing issue #3178. Line 165 should be a bug. Boundary restrictable needs to be fixed.