hostname and fqdn validations

Use nested module/class definitions instead of compact style.