PosInformatique.Foundations.EmailAddresses
1.0.0
Prefix Reserved
dotnet add package PosInformatique.Foundations.EmailAddresses --version 1.0.0
NuGet\Install-Package PosInformatique.Foundations.EmailAddresses -Version 1.0.0
<PackageReference Include="PosInformatique.Foundations.EmailAddresses" Version="1.0.0" />
<PackageVersion Include="PosInformatique.Foundations.EmailAddresses" Version="1.0.0" />
<PackageReference Include="PosInformatique.Foundations.EmailAddresses" />
paket add PosInformatique.Foundations.EmailAddresses --version 1.0.0
#r "nuget: PosInformatique.Foundations.EmailAddresses, 1.0.0"
#:package PosInformatique.Foundations.EmailAddresses@1.0.0
#addin nuget:?package=PosInformatique.Foundations.EmailAddresses&version=1.0.0
#tool nuget:?package=PosInformatique.Foundations.EmailAddresses&version=1.0.0
PosInformatique.Foundations.EmailAddresses
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
IFormattableandIParsable<T>for seamless integration with .NET APIs - Implicit conversion between
stringandEmailAddress
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
Links
| 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 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. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on PosInformatique.Foundations.EmailAddresses:
| Package | Downloads |
|---|---|
|
PosInformatique.Foundations.EmailAddresses.Json
Provides a System.Text.Json converter for the MimeType value object. Enables seamless serialization and deserialization of MIME types within JSON documents. |
|
|
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). |
|
|
PosInformatique.Foundations.Emailing
Provides a lightweight, template-based emailing infrastructure for .NET. Allows registering strongly-typed email templates, instantiating emails from models, and sending them through pluggable providers (e.g. Azure Communication Service). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 257 | 11/19/2025 |
| 1.0.0-rc.4 | 183 | 11/19/2025 |
| 1.0.0-rc.3 | 182 | 11/18/2025 |
| 1.0.0-rc.2 | 175 | 11/18/2025 |
| 1.0.0-rc.1 | 181 | 11/18/2025 |
1.0.0
- Initial release with strongly-typed EmailAddress value object.