In our app, we allow users to create features on maps. The boundaries of these features will later be converted into real-life latitude/longitude coordinates, but does not make sense if features are created outside the actual boundaries of the map.

In the above screenshot, I'd like to prevent the blue feature from being drawn so that its upper edge stays inside the actual map.
How could I do that? I couldn't find any reference to this in OpenLayers examples or documentation.
(Currently on 2.12-rc1)