Refactor POST input validation