Created a custom library to validate form data and used that in the controllers.