It’s often legal to discriminate by age (that is literally what the drinking, driving, and smoking age limits are), but I believe that the government must have a compelling interest in the restriction. This one seems extremely shaky to me, but as is common it’s likely that a lot of people will end up paying fines since they can’t afford to fight an order that may not stand up to judicial scrutiny.