Rewrite validations in a functional style