improved validation of port specification