Refactor class name validations