Now, such a policy would not be effective if the allergy is as severe as to be triggered by being breathed on by someone who had eaten the offending food (or by touching something they touched, like a door handle or water fountain faucet), but no policy would be. Aside from the fact that you cannot control what other children eat before school, consider the inevitable exposure to people in malls, airplanes, grocery stores, etc etc etc. Any measures would necessarily be more oppressive than even forcing schools to shutter all the windows in order to not threaten a child with sunlight allergies (rare, but such an allergy exists).
Life doesn’t come with guarantees.