refactor(input): wrapped validation logic in helper function

Closes #5643