swift workflow codecov License: MIT Issues Releases


A Swift implementation of an international email address syntax validator based on RFC5321 & RFC5322. Since email addresses are
local @ remote the validator also includes IPAddressSyntaxValidator and EmailHostSyntaxValidator classes. This
Swift Package does not require an Internet connection at runtime and is entirely self contained.

RFC5321 – Simple Mail Transfer Protocol

RFC5322 – Internet Message Format

Domains are validated against the Public Suffix List at https://publicsuffix.org . To update the built-in suffix list
(PublicSuffixRulesRegistry.swift) use the Utilities/update-suffix.swift script.

Public Suffix List last updated on 2022-01-22 10:48:00 EST


if EmailSyntaxValidator.match("[email protected]") {
    print("[email protected] respects Email syntax rules")


if IPAddressSyntaxValidator.matchIPv6("::1") {
    print("::1 is a valid IPv6 address")

if IPAddressSyntaxValidator.matchIPv4("") {
    print(" is a valid IPv4 address")

if IPAddressSyntaxValidator.match("") {
    print(" is a valid IP address")

if IPAddressSyntaxValidator.match("fe80::1") {
    print("fe80::1 is a valid IP address")


Validates if the email’s host name is following expected syntax rules and whether it is part of a known public suffix. Does NOT validate if the domain actually exists or even allowed by the registrar.

if EmailHostSyntaxValidator.match("yahoo.com") {
    print("yahoo.com has valid email host syntax")


View Github