(maint) Refactoring module name validation to be less obtuse.

Previously the code that validated module names took a pessimistic
approach, validating conformance only to assert unrelated non-conformance.
As it turns out, this is messy to read and understand, so this change
rewrites the logic in a more straightforward manner.