(Note that if the washing machine has digital controls, rather than a mechanical switch, it almost certainly uses an electronic variable pressure sensor to detect the water level. These three-wire sensors are easy to interface, but we'll leave them for another time).
Controlling an electric water pump, to keep a container full of water. Just as in a washing machine, the depth of the water can be sensed from a hose connected to the base of the container.The advantage over a float switch is that the level is easily adjustable. Providing a low water level warning eg, the switch could be used to activate a buzzer or light if the liquid level in a tank drops below an adjustable point.