Refactor forbidden/2 and resource validation helper functions.