Skip to content

Add Domain (net) #47

@vhrcgcom

Description

@vhrcgcom

Description

Implement Domain as a ValueObject in the net module.

Spec: valid domain name without scheme

Implementation checklist

  • Create src/net/domain.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/net/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Type Alias
Input String DomainInput
Output String — lowercase DomainOutput

Normalization

Trim, convert to lowercase.

Validation

  • Must not contain a scheme (:// is forbidden — it is a hostname, not a URL).
  • Each label (segment between dots) must be 1–63 characters.
  • Labels may only contain ASCII letters, digits, and hyphens; no leading or trailing hyphen per label.
  • At least one dot (single-label names like "localhost" are rejected).
  • Total length must not exceed 253 characters.

Extra methods

  • tld() -> &str — the last label after the final dot, e.g. "com", "cz".

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions