Use a switch expression to get validator