Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:12:76

So he began ˹the search˺ with their bags before the bag of his brother; then he extracted it from the bag of his brother. Thus did We plan for Joseph. He could not have taken his brother within the religion of the king except that Allah willed. We raise in degrees whom We will, but over every possessor of knowledge is one ˹more˺ knowing.  

And so he began with their sacks, and searched them, before his brother’s sack, lest he be accused ˹of the theft˺; then he pulled it, the drinking-cup, out of his brother’s sack. God, exalted be He, says: Thus, ˹through such˺ contrivance, did We contrive for Joseph, ˹thus˺ We taught him how to devise a plot to take his brother; he, Joseph, could not have taken his brother, as a slave, on account of theft, according to the king’s law, ˹according˺ to the laws of the king of Egypt — since his ˹a thief’s˺ requital according to his law would have been a beating and a penalty of twice ˹the value of˺ the stolen item, but not enslavement — unless God willed, for him to be taken according to the law of his father ˹Jacob˺; in other words, he was only able to take him with God’s will, by God’s inspiring him to ask his brothers ˹about the nature of requital˺ and their responding according to ˹what is decreed by˺ their customary practice. We raise by degrees whom We will (read with a genitive annexation, darajāti man nashā’, or ˹simply˺ with nunation, darajātin man nashā’), in terms of knowledge, as ˹We did˺ with Joseph; and above every man of knowledge, from among creatures, is one who knows better, better than him ˹and so on˺ until it ends with God, exalted be He.
القرآن:١٢:٧٦

فَبَدَأَ بِأَوْعِيَتِهِمْ قَبْلَ وِعَاءِ أَخِيهِ ثُمَّ اسْتَخْرَجَهَا مِنْ وِعَاءِ أَخِيهِ ۚ كَذَٰلِكَ كِدْنَا لِيُوسُفَ ۖ مَا كَانَ لِيَأْخُذَ أَخَاهُ فِي دِينِ الْمَلِكِ إِلَّا أَنْ يَشَاءَ اللَّهُ ۚ نَرْفَعُ دَرَجَاتٍ مَنْ نَشَاءُ ۗ وَفَوْقَ كُلِّ ذِي عِلْمٍ عَلِيمٌ  

{فبدأ بأوعيتهم} ففتشها {قبل وعاء أخيه} لئلا يتهم {ثم استخرجها} أي السقاية {من وعاء أخيه} قال تعالى: {كذلك} الكيد {كدنا ليوسف} علمناه الاحتيال في أخذ أخيه {ما كان} يوسف {ليأخذ أخاه} رقيقا عن السرقة {في دين الملك} حكم ملك مصر لأن جزاءه عنده الضرب وتغريم مثلي المسروق لا الاسترقاق {إلا أن يشاء الله} أخذه بحكم أبيه أي لم يتمكن من أخذه إلا بمشيئة الله بإلهامه سؤال إخوته وجوابهم بسنتهم {نرفع درجاتِ من نشاء} بالإضافة والتنوين في العلم كيوسف {وفوق كل ذي علم} من المخلوقين {عليم} أعلم منه حتى ينتهي إلى الله تعالى.