The Messenger of Allah ﷺ said, "Whoever vows to obey Allah, let him obey Him, and whoever vows to disobey Allah, let him not disobey Him."
أخبرنا قتيبة عن مالك عن طلحة بن عبد الملك عن القاسم
أن رسول الله ﷺ قال من نذر أن يطيع الله فليطعه ومن نذر أن يعصي الله فلا يعصه
Bukhari transmitted it in the Book of Oaths and Vows, chapter on vows in obedience, and "whatever you spend or vow to spend", hadith no. 6696, from the hadith of Malik, with this wording. It is also found in Muwatta (Yahya), 2/476, and in Kubra, hadith no. 04748.