The dreams of the Prophets عليهم الصلاة والسلام were all true - which was a valuable support to the veracity of their message. Whether they were sleeping or awake, Shaytaan was not allowed to make them envision falsehood.
Sa'eed Ibn Jubayr رحمه الله reported that Ibn 'Abbaas رضي الله عنهما said: "The Prophets' dreams are part of revelation." [1]
Imaam Ahmad رحمه الله said: "The dreams of the Prophets عليهم الصلاة والسلام were part of revelation. Only ignorant individuals would belittle dreams and claim that they have no consequence." [2]
Dreams are, therefore, included in the meaning of the aayah:
"And it is not for any human being that Allaah should speak to him except by revelation or from behind a partition or that He sends a messenger to reveal, by His permission, what He wills. Indeed, He is Most High and Wise." (Sooratush-Shooraa, 42:51)
Dreams are part of the revelation that the Prophet صلى الله عليه وسلم received from his Lord سبحانه و تعالى.
In particular, our Prophet Muhammad صلى الله عليه وسلم was alert, even during sleep. His dreams were as truthful as what he witnessed during his wakefulness. Ummul Mu'mineen 'Aa'ishah رضي الله عنها reported that the Prophet told her: "O 'Aa'ishah, my eyes sleep, but my heart does not." [3]
Because of this, Mu'aadh رضي الله عنه said: "Everything that the Messenger of Allaah صلى الله عليه وسلم saw during sleep or while awake is true." [4]
In fact, the Prophet's صلى الله عليه وسلم great mission started with true dreams, as Ummul Mu'mineen 'Aa'ishah رضي الله عنها reported: "The first kind of revelation that the Messenger of Allaah صلى الله عليه وسلم received was true visions during sleep. He would not have a dream except that it would later materialise as clear as morning." [5] [6]
Notes:
[1] Recorded by Ibn Jareer, Ibn Abi 'Aasim, and others. Verified to be Hasan by Shaykh al-Albaani رحمه الله.
[2] Reported by Abu Ya'laa in Tabaqaat ul-Hanaabilah, 1:29.
[3] Recorded by al-Bukhaari, Muslim, and others.
[4] Recorded by Ibn Abi 'Aasim. Verified to be authentic by Shaykh al-Albaani رحمه الله.
[5] Recorded by al-Bukhaari, Muslim, and others.
[6] The Dreamers Handbook