Domain

public struct Domain

Type that wraps a validated domain name (as per RFCs 952 and 1123)

The name of a Domain value should be considered safe for use in contexts which require a valid domain name, as any invalid domain formulations would be rejected by the contructor.

  • Domain formatting error.

    See more

    Declaration

    Swift

    public enum Format : LocalizedError
  • Domain size error.

    See more

    Declaration

    Swift

    public enum Size : LocalizedError
  • The validated domain name (as a String).

    Declaration

    Swift

    public let name: String
  • Creates a new Domain value which wraps a validated domain name.

    And invalid name causes the constructor to throw.

    Note

    The validity of the given name is judged by RFCs 952 and RFC-1123 which state, in part:

    “A ‘name’ (Net, Host, Gateway, or Domain name) is a text string … drawn from the alphabet (A-Z), digits (0-9), minus sign (-) … The first character must be an alpha character. The last character must not be a minus sign.”

    and

    “The restriction on the first character is relaxed to allow either a letter or a digit. Host software … SHOULD handle host names of up to 255 characters.”

    Throws

    Domain.Format.invalid(String) if the given name is an invalid domain.

    Declaration

    Swift

    public init(name: String) throws

    Parameters

    name

    The domain name to be wrapped (if validated).

  • Defines whether two Domains are equal based on their name properties.

    Note

    RFC 952 states “No distinction is made between upper and lower case.” And so the names’ equality is determined with a case-insensitive compare.

    Declaration

    Swift

    public static func == (lhs: Domain, rhs: Domain) -> Bool