lib: refactor isLegalPort, move to validators
isLegalPort was used multiple places in the same way -- to validate the port and throw if necessary. Moved into internal/validators.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines