Anti-siphon valves are a great example of how building codes evolve. They also show how the code can contain rules that seem to make no sense but actually solve significant problems. Most building codes now require anti-siphon valve in several different places in a house, including all external hose connections and sometimes in toilet fill valves.
First, let's define a siphon. A siphon is any pipe, hose or tube that is used to move a liquid from a higher location to a lower location. To use a siphon, you fill the pipe or hose with the liquid and stick one end of the pipe in the liquid at the higher location. Then you let the liquid start draining at the lower location. As the liquid drains out of the pipe at the lower location, a vacuum develops that sucks the water from the higher location. Gravity and suction do all the work, so no pump is required! You can use siphons to drain ponds, empty barrels, remove gasoline from a gas tank, etc.
Here's the problem anti-siphon valves solve: Let's say you take your garden hose and you stick it in the 300-gallon aquarium you have in your upstairs bedroom to fill the aquarium. When you turn on the water, you fill the hose with water. As the aquarium fills, the end of the hose inside the aquarium gets covered with water. If the water pressure fails (for example, because you live in a rural area with a private well and the power goes out, or in the city because someone opens a fire hydrant and significantly lowers the water pressure on your block), what will happen is that the water in the aquarium will siphon back through the hose into the water system. So the next time you turn on the water in the kitchen, you are drinking aquarium water. Yuck! The problem is even worse if you are using the hose to fill a pesticide tank. In the case of a lawn irrigation system, if there is standing water in the yard then the siphon effect can suck fertilizer, weed killers, dog poop and all sorts of other things into your home's plumbing. Double-yuck!
The anti-siphon valve prevents all of this. An anti-siphon valve is nothing more than a one-directional valve. It can be as simple as a spring-loaded flap that lets water flow in only one direction.
A key thing to note is that many people skip the anti-siphon valve. Either they don't know about it, or they don't understand it, or they think it costs too much or they simply don't like to be "told what to do." In the process, they endanger their own health and the health of their neighbors, because there is an actual problem that the anti-siphon valve solves. That's why there are building codes and building inspections.
Here are some interesting links: