 It is prohibited all the time according to the "Maliki" and "Shafi"`i "madhaahib".Zahiri Imam Ibn Hazm regards masturbation as permissible.Scholars have also stated that masturbation would not be necessary if one realizes the flexible approach Islam takes to marriage.