Added validators for package and package group rules

Also contains some refactored code and fixes for publish.
Merge pull request #2017 from parthaa/package-rules-part-deux

Added validators for package and package group rules