Naming Conventions are necessary in IT-Business.
- only lowercase
No starting, trailing [_.-]
- Domain-part may exist
- Minimum 1 char username
Minimum 1 char domain after "@"
Local-part may contain [a-z0-9_-$]
Domain-part may contain [a-z0-9-.]
- Periods only in domain-part
Compatibility to Samba with trailing "$" in username
PCRE grep -P
Tested against this file
1 -invaliduser 2 -invalid_user 3 -invalid-user 4 .invaliduser 5 invalid_user_ 6 invalid_user- 7 invalid_user. 8 invalid-user_ 9 invalid-user- 10 invalid-user. 11 invalid.user 12 invaliduser_ 13 invaliduser- 14 firstname.lastname@example.org-.tld 15 email@example.com.-tld 16 firstname.lastname@example.org.-tld. 17 invalid-user@subdomain._2ld-.tld 18 invalid-user@subdomain._2ld.tld 19 invaliduser@-subdomain-.2ld.tld. 20 invaliduser@-subdomain.2ld.tld 21 invaliduser@-subdomain.2ld.tld. 22 invaliduser@sub-domain.-2ld.tld 23 invaliduser@sub-domain.-2ld.tld. 24 invaliduser@subdomain-.2ld.tld 25 email@example.com. 26 firstname.lastname@example.org. 27 v 28 validuser 29 valid_user 30 valid_user$ 31 valid-user 32 valid-user$ 33 validuser$ 34 email@example.com 35 firstname.lastname@example.org 36 email@example.com 37 firstname.lastname@example.org 38 email@example.com 39 firstname.lastname@example.org 40 email@example.com 41 firstname.lastname@example.org 42 email@example.com 43 firstname.lastname@example.org 44 email@example.com 45 firstname.lastname@example.org
constraints from RFC 608:
- up to 48 characters drawn from the alphabet (A-Z), digits (0-9), and the minus sign (-) ... specifically, no blank or space characters allowed;
- no distinction between upper and lower case letters;
- the first character is a letter;
- the last character is NOT a minus sign;
- no other restrictions on content or syntax.
no underscores "_" and it doesn't matter if Microsoft DNS allows it.
RFC 810 states
<official hostname> ::= <name> <name> ::= <letter>[*[<letter-or-digit-or-hyphen>]<letter-or-digit>]
Here is a regex to check hostnames.
Take a look at IETF RFC1034 DOMAIN NAMES - CONCEPTS AND FACILITIES
3. DOMAIN NAME SPACE and RESOURCE RECORDS 3.1. Name space specifications and terminology The domain name space is a tree structure. Each node and leaf on the tree corresponds to a resource set (which may be empty). The domain system makes no distinctions between the uses of the interior nodes and leaves, and this memo uses the term "node" to refer to both. Each node has a label, which is zero to 63 octets in length. Brother nodes may not have the same label, although the same label can be used for nodes which are not brothers. One label is reserved, and that is the null (i.e., zero length) label used for the root. The domain name of a node is the list of the labels on the path from the node to the root of the tree. By convention, the labels that compose a domain name are printed or read left to right, from the most specific (lowest, farthest from the root) to the least specific (highest, closest to the root). Internally, programs that manipulate domain names should represent them as sequences of labels, where each label is a length octet followed by an octet string. Because all domain names end at the root, which has a null string for a label, these internal representations can use a length byte of zero to terminate a domain name. By convention, domain names can be stored with arbitrary case, but domain name comparisons for all present domain functions are done in a case-insensitive manner, assuming an ASCII character set, and a high order zero bit. This means that you are free to create a node with label "A" or a node with label "a", but not both as brothers; you could refer to either using "a" or "A". When you receive a domain name or label, you should preserve its case. The rationale for this choice is that we may someday need to add full binary domain names for new services; existing services would not be changed. When a user needs to type a domain name, the length of each label is omitted and the labels are separated by dots ("."). Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this property to distinguish between: - a character string which represents a complete domain name (often called "absolute"). For example, "poneria.ISI.EDU." - a character string that represents the starting labels of a domain name which is incomplete, and should be completed by local software using knowledge of the local domain (often called "relative"). For example, "poneria" used in the ISI.EDU domain. Relative names are either taken relative to a well known origin, or to a list of domains used as a search list. Relative names appear mostly at the user interface, where their interpretation varies from implementation to implementation, and in master files, where they are relative to a single origin domain name. The most common interpretation uses the root "." as either the single origin or as one of the members of the search list, so a multi-label relative name is often one where the trailing dot has been omitted to save typing. To simplify implementations, the total number of octets that represent a domain name (i.e., the sum of all label octets and label lengths) is limited to 255. A domain is identified by a domain name, and consists of that part of the domain name space that is at or below the domain name which specifies the domain. A domain is a subdomain of another domain if it is contained within that domain. This relationship can be tested by seeing if the subdomain's name ends with the containing domain's name. For example, A.B.C.D is a subdomain of B.C.D, C.D, D, and " ".
- The domain name space is a tree structure. Each node and leaf on the tree corresponds to a resource set (which may be empty).
- Each node has a label, which is zero to 63 octets in length.
the labels are separated by dots (".").
- A domain name (i.e., the sum of all label octets and label lengths) is limited to 255.
- One label is reserved, and that is the null (i.e., zero length) label used for the root.