Muwatta Malik, Book 37, Hadith 1460 (In-Book)

Malik related to me from Yahya ibn Said from Abu Bakr ibn Hazm that a boy from Ghassan was dying in Madina while his heir was in Syria. That was mentioned to Umar ibn al-Khattab. It was said to him, "So-and-so is dying. Shall he make a bequest?" He said, "Let him make a bequest." Yahya ibn Said said that Abu Bakr had said, "He was a boy of ten or twelve years." Yahya said, "He willed the well of Jusham, and his people sold it for 30,000 dirhams." Yahya said that he heard Malik say, "The generally agreed-on way of doing things in our community is that a simpleton, an idiot, or a lunatic who recovers at times, can make wills if they have enough of their wits about them to recognise what they will. Someone who has not enough wits to recognise what he wills, and is overcome in his intellect, cannot make a bequest."

وَحَدَّثَنِي مَالِكٌ، عَنْ يَحْيَى بْنِ سَعِيدٍ، عَنْ أَبِي بَكْرِ بْنِ حَزْمٍ، أَنَّ غُلاَمًا، مِنْ غَسَّانَ حَضَرَتْهُ الْوَفَاةُ بِالْمَدِينَةِ وَوَارِثُهُ بِالشَّامِ فَذُكِرَ ذَلِكَ لِعُمَرَ بْنِ الْخَطَّابِ فَقِيلَ لَهُ إِنَّ فُلاَنًا يَمُوتُ أَفَيُوصِي قَالَ فَلْيُوصِ ‏.‏ قَالَ يَحْيَى بْنُ سَعِيدٍ قَالَ أَبُو بَكْرٍ وَكَانَ الْغُلاَمُ ابْنَ عَشْرِ سِنِينَ أَوِ اثْنَتَىْ عَشْرَةَ سَنَةً ‏.‏ قَالَ فَأَوْصَى بِبِئْرِ جُشَمٍ فَبَاعَهَا أَهْلُهَا بِثَلاَثِينَ أَلْفَ دِرْهَمٍ ‏.‏ قَالَ يَحْيَى سَمِعْتُ مَالِكًا يَقُولُ الأَمْرُ الْمُجْتَمَعُ عَلَيْهِ عِنْدَنَا أَنَّ الضَّعِيفَ فِي عَقْلِهِ وَالسَّفِيهَ وَالْمُصَابَ الَّذِي يُفِيقُ أَحْيَانًا تَجُوزُ وَصَايَاهُمْ إِذَا كَانَ مَعَهُمْ مِنْ عُقُولِهِمْ مَا يَعْرِفُونَ مَا يُوصُونَ بِهِ فَأَمَّا مَنْ لَيْسَ مَعَهُ مِنْ عَقْلِهِ مَا يَعْرِفُ بِذَلِكَ مَا يُوصِي بِهِ وَكَانَ مَغْلُوبًا عَلَى عَقْلِهِ فَلاَ وَصِيَّةَ لَهُ ‏.‏

sunnah.com

also referenced under: Book 37, Hadith 3 (USC-MSA)