Completely legal, I think. Condos can enforce reasonable rules like that. That’s just how it is. Although I do think it’s a weird rule. But I guess your condo is just conservative, that’s all.
YES! IT IS WEIRD! I had no idea this was a rule when I bought my unit. I’m not saying it’s a dealbreaker but it’s definitely offputting. I’ve heard of rules that strictly require swimwear in the pool. But this just seems backwards.
HOAs and condos are pretty well-known for strange rules. This no bikini thing is definitely one of them but I see no harm in enforcing such a rule. I would be worried if it were the other way around and your HOA REQUIRED bikinis.