Yes, but you cannot reach the gates until you beat the 8th gym. Only on red, blue and yellow of the gameboy color, advance, etc. could you reach the gates, but of course, couldn't pass till badges are obtained.
So in this case, the guard being able to tell you you don't have one is basically an anti-walk-through walls effort.