However, the correct view is that there is some detail to this issue. If the condition that the buyer not sell serves an interest connected to either of the contracting parties or to the subject matter of the contract, then the correct view is that it is valid.
An example of an interest connected to one of the contracting parties is this: I know that this man needs a house and I want to sell him my house, but I know that he does not manage his affairs well. I may sell it to him in the morning, only for him to sell it by the end of the day. Yet I only wish to sell it to him so that he may benefit from it and live in it. So I say to him, “I will not sell you this house except on the condition that you do not sell it,” and he accepts this commitment. This serves the interest of one of the contracting parties—the buyer.
An example of an interest connected to the subject matter of the contract is that I have a slave of high standing, and a man whom I trust and consider reliable comes to me and says, “Sell me your slave.” I say, “I will sell him to you on condition that you do not sell him,” because I fear that, if he sells my slave to some ignorant man, he may wrong and humiliate him. So I say, “Yes, I will sell you my slave on condition that you do not sell him.” Here, the interest relates to the slave, who is the subject matter of the contract.
Likewise, the correct view concerning the second scenario is that it is permissible. A certain person may be known for evil and corruption, while I have a slave. Then a trustworthy and reliable man comes to me, and I say, “There is no objection to selling you the slave, but on condition that you do not sell him specifically to so-and-so.” This serves the interest of the subject matter of the contract.
Similarly, if I have, for example, a camel, I may say, “I will sell you this camel on condition that you do not sell it to so-and-so,” because he is known not to show mercy to animals: he burdens them with what they cannot bear, beats them without cause, starves them, and leaves them exposed in the cold. Thus, I say, “On condition that you do not sell it to so-and-so,” out of fear that he may mistreat this animal. The correct view is that this is permissible, because it serves the interest of the subject matter of the contract.