Add a validate function.