The law addressed this centuries ago. The general rule is that you can enforce such rules for a generation plus twenty years. That may seem like a long time, but the rule prevents the "cold hand from the grave" dictating how living people should act.
https://en.wikipedia.org/wiki/Rule_against_perpetuities
In this case, the farmer should have talked to a lawyer first. There are ways to set thing up to prevent misuse.