What's a "better solution" is the part of your question that would need to be refined. If it is to be evaluated in terms of clarity, I find yours pretty legible, and as such very good in terms of maintenance : it reflects business rules, so it's quite easy to update if requirements were to change. As opposed to one-liners, for instance. And performancewise, no input value requires more than 4 tests ; one-liners wouldn't test less, I guess. Maybe create and use constants for strings, as they might change in bulk. My 20 cents. As @T Go to codereview ;-) —
Alain BECKER 56 secs ago