PosInformatique.Foundations.EmailAddresses 1.0.0-alpha.4

Prefix Reserved
This is a prerelease version of PosInformatique.Foundations.EmailAddresses.
dotnet add package PosInformatique.Foundations.EmailAddresses --version 1.0.0-alpha.4
                    
NuGet\Install-Package PosInformatique.Foundations.EmailAddresses -Version 1.0.0-alpha.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PosInformatique.Foundations.EmailAddresses" Version="1.0.0-alpha.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.EmailAddresses" Version="1.0.0-alpha.4" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.EmailAddresses" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PosInformatique.Foundations.EmailAddresses --version 1.0.0-alpha.4
                    
#r "nuget: PosInformatique.Foundations.EmailAddresses, 1.0.0-alpha.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PosInformatique.Foundations.EmailAddresses@1.0.0-alpha.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PosInformatique.Foundations.EmailAddresses&version=1.0.0-alpha.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.EmailAddresses&version=1.0.0-alpha.4&prerelease
                    
Install as a Cake Tool

PosInformatique.Foundations.EmailAddresses

NuGet version NuGet downloads

Introduction

This package provides a strongly-typed EmailAddress value object that ensures only valid email addresses (RFC 5322 compliant) can be instantiated.

It simplifies validation, parsing, comparison, and string formatting of email addresses.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.EmailAddresses

Features

  • Strongly-typed email address validation and parsing
  • Ensures email addresses are formatted according to RFC 5322
  • Email values are always stored and compared in lowercase to avoid case-sensitive inconsistencies
  • Implements IEquatable<T>, IComparable<T>, and operator overloads for equality and ordering
  • Provides IFormattable and IParsable<T> for seamless integration with .NET APIs
  • Implicit conversion between string and EmailAddress

Use cases

  • Validation: prevent invalid emails from being stored in your domain entities.
  • Type safety: avoid dealing with raw strings when working with email addresses.
  • Conversion: use implicit/explicit parsing and formatting seamlessly when working with APIs.
  • Consistency: ensures a single, robust email parsing logic across all projects.

Examples

Create and validate email addresses

// Implicit conversion from string
EmailAddress email = "john.doe@example.com";

// Access parts
Console.WriteLine(email.UserName); // "john.doe"
Console.WriteLine(email.Domain);   // "example.com"

// Validation
bool valid = EmailAddress.IsValid("test@domain.com"); // true
bool invalid = EmailAddress.IsValid("not-an-email");  // false

Parsing

var email = EmailAddress.Parse("alice@company.org");
Console.WriteLine(email); // "alice@company.org"

if (EmailAddress.TryParse("bob@company.org", out var parsed))
{
    Console.WriteLine(parsed.Domain); // "company.org"
}

Comparisons

var a = (EmailAddress)"alice@company.com";
var b = (EmailAddress)"bob@company.com";

Console.WriteLine(a == b);  // false
Console.WriteLine(a != b);  // true
Console.WriteLine(a < b);   // true, alphabetic order

var list = new List<EmailAddress> { b, a };
list.Sort(); // Sorted alphabetically
Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on PosInformatique.Foundations.EmailAddresses:

Package Downloads
PosInformatique.Foundations.EmailAddresses.Json

Provides a System.Text.Json converter for the EmailAddress value object. Enables seamless serialization and deserialization of RFC 5322 compliant email addresses within JSON documents. Designed to integrate smoothly with System.Text.Json options, ensuring consistent validation and parsing during JSON processing.

PosInformatique.Foundations.EmailAddresses.EntityFramework

Provides Entity Framework Core integration for the EmailAddress value object. Enables seamless mapping of RFC 5322 compliant email addresses as strongly-typed properties in Entity Framework Core entities, with safe conversion to string.

PosInformatique.Foundations.EmailAddresses.FluentValidation

Provides a FluentValidation extension to validate email addresses using the strongly-typed EmailAddress value object (RFC 5322 compliant).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.4 37 9/27/2025
1.0.0-alpha.3 70 9/26/2025
1.0.0-alpha.2 68 9/26/2025
1.0.0-alpha.1 106 9/25/2025

1.0.0
 - Initial release with strongly-typed EmailAddress value object.