An deed that is not in harmony with the religion is rejected
MUSLIM 1718b:
from Saʾalt al-Qāsim b. Muḥammad —
I asked al-Qasim b. Muhammad about a man who has three dwellings and bequeathed one third of each dwelling. He said: All of that is combined into a single dwelling. Then he said: Aishah told me that the Messenger of Allah ﷺ said: “Whoever does a deed that is not in accordance with our command, it is rejected.”
مسلم ١٧١٨b:
عن سءلت القاسم بن محمد —
سَأَلْتُ الْقَاسِمَ بْنَ مُحَمَّدٍ عَنْ رَجُلٍ لَهُ ثَلاَثَةُ مَسَاكِنَ فَأَوْصَى بِثُلُثِ كُلِّ مَسْكَنٍ مِنْهَا قَالَ: يُجْمَعُ ذَلِكَ كُلُّهُ فِي مَسْكَنٍ وَاحِدٍ. ثُمَّ قَالَ: أَخْبَرَتْنِي عَائِشَةُ أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ: «مَنْ عَمِلَ عَمَلاً لَيْسَ عَلَيْهِ أَمْرُنَا فَهُوَ رَدٌّ».