Refactors form validation so it's shorter