EmailGuard 1.0.1
dotnet add package EmailGuard --version 1.0.1
NuGet\Install-Package EmailGuard -Version 1.0.1
<PackageReference Include="EmailGuard" Version="1.0.1" />
<PackageVersion Include="EmailGuard" Version="1.0.1" />
<PackageReference Include="EmailGuard" />
paket add EmailGuard --version 1.0.1
#r "nuget: EmailGuard, 1.0.1"
#:package EmailGuard@1.0.1
#addin nuget:?package=EmailGuard&version=1.0.1
#tool nuget:?package=EmailGuard&version=1.0.1
EmailGuard
Zero-dependency, offline email validation for .NET.
EmailGuard validates email addresses through a fast three-step pipeline — no network calls, no external dependencies.
Features
| Step | What it does | Speed |
|---|---|---|
| 1. Quick Guard | Compiled regex rejects obvious junk (missing @, spaces, no domain dot) |
⚡ ~nanoseconds |
| 2. RFC Validation | Enforces RFC 5321/5322 rules: atext chars, dot positions, length limits | ⚡ ~microseconds |
| 3. TLD Check | Verifies the domain's TLD against a static IANA root zone list | ⚡ ~microseconds |
Highlights
- 🚫 Zero dependencies — pure .NET, nothing to install
- 🔌 Fully offline — no DNS lookups, no HTTP calls
- 🎯 Multi-target — supports
net8.0,net9.0,net10.0 - 📋 Detailed results — tells you which step failed, not just pass/fail
- ⚡ Fast — source-generated regex,
Span<T>-based parsing,HashSet<T>TLD lookup
Installation
dotnet add package EmailGuard
Quick Start
using EmailGuard;
// Simple boolean check
if (EmailValidator.IsValid("user@example.com"))
Console.WriteLine("Valid!");
// Detailed result
var result = EmailValidator.Validate("user@example.com");
switch (result)
{
case EmailValidationResult.Valid:
Console.WriteLine("✅ Valid email address.");
break;
case EmailValidationResult.InvalidFormat:
Console.WriteLine("❌ Bad format.");
break;
case EmailValidationResult.RfcViolation:
Console.WriteLine("❌ RFC 5321/5322 violation.");
break;
case EmailValidationResult.InvalidTld:
Console.WriteLine("❌ Unknown TLD.");
break;
}
API Reference
EmailValidator.Validate(string? email)
Returns an EmailValidationResult enum:
| Value | Meaning |
|---|---|
Valid |
Passed all three validation steps |
InvalidFormat |
Failed the quick regex guard (step 1) |
RfcViolation |
Failed RFC 5321/5322 structural checks (step 2) |
InvalidTld |
Domain TLD not found in the IANA list (step 3) |
EmailValidator.IsValid(string? email)
Returns true if the email passes all validation steps; false otherwise.
TldValidator.IsValidTld(string domain)
Returns true if the domain's TLD is in the known IANA list.
RFC Rules Enforced (Step 2)
- Exactly one
@separating local-part and domain - Total address length ≤ 254 characters
- Local-part length ≤ 64 characters
- Local-part: only RFC 5322
atextcharacters + dots; no leading, trailing, or consecutive dots - Domain labels: 1–63 characters each, alphanumeric + hyphens, no leading/trailing hyphens
- At least two domain labels (e.g.,
example.com)
TLD List (Step 3)
The TLD list is sourced from the IANA Root Zone Database and is embedded as a static HashSet<string>. It includes all country-code, generic, and internationalized (punycode xn--) TLDs.
Last updated: 2026-02-24
To update, replace the list in TldValidator.cs and bump the version.
Project Structure
EmailGuard/
├── src/
│ └── EmailGuard/ # The NuGet package library
├── tests/
│ └── EmailGuard.Tests/ # xUnit unit + smoke tests
├── samples/
│ └── EmailGuard.Sample/ # Console demo app
├── EmailGuard.sln
├── README.md
└── LICENSE
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.