Factor out master name validation