Validate document before insert

I doing custom validation on some fields
I have used validate function on controller like that

def validate(self):
	if self.status == 'delivering' :
		if not self.deliveryman :
			msgprint(_("Please choose deliveryman "))
	frappe.db.set(self, 'start_dt',"%Y-%m-%d %H:%M:%S"))

but I do not need document to be saved on after check validation
how can i make frappe not to save document ?

try throw instead of msgprint

frappe.throw(__("Please choose deliveryman "));
1 Like