Split validate_array_of_hashes into its own function