No defendant shall be discharged on a writ of habeas corpus because of informality in the commitment or in the proceedings prior thereto, provided there has been substantial compliance with this article.