PosInformatique.Foundations.EmailAddresses.FluentValidation
1.0.0-alpha.4
Prefix Reserved
dotnet add package PosInformatique.Foundations.EmailAddresses.FluentValidation --version 1.0.0-alpha.4
NuGet\Install-Package PosInformatique.Foundations.EmailAddresses.FluentValidation -Version 1.0.0-alpha.4
<PackageReference Include="PosInformatique.Foundations.EmailAddresses.FluentValidation" Version="1.0.0-alpha.4" />
<PackageVersion Include="PosInformatique.Foundations.EmailAddresses.FluentValidation" Version="1.0.0-alpha.4" />
<PackageReference Include="PosInformatique.Foundations.EmailAddresses.FluentValidation" />
paket add PosInformatique.Foundations.EmailAddresses.FluentValidation --version 1.0.0-alpha.4
#r "nuget: PosInformatique.Foundations.EmailAddresses.FluentValidation, 1.0.0-alpha.4"
#:package PosInformatique.Foundations.EmailAddresses.FluentValidation@1.0.0-alpha.4
#addin nuget:?package=PosInformatique.Foundations.EmailAddresses.FluentValidation&version=1.0.0-alpha.4&prerelease
#tool nuget:?package=PosInformatique.Foundations.EmailAddresses.FluentValidation&version=1.0.0-alpha.4&prerelease
PosInformatique.Foundations.EmailAddresses.FluentValidation
Introduction
This package provides a FluentValidation extension for validating email addresses using the EmailAddress value object.
It ensures that only valid RFC 5322 compliant email addresses are accepted when validating string properties.
null
string values are ignored (considered valid).- To require non-null values, combine with the
NotNull()
or/andNotEmpty()
.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.EmailAddresses.FluentValidation
This package depends on the base package PosInformatique.Foundations.EmailAddresses.
Features
- FluentValidation extension for email address validation
- Uses the same parsing and validation rules as the EmailAddress value object
- Clear and consistent error messages
null
values are accepted (combine withNotNull()
validator to forbid nulls)
Usage
Basic validation
using FluentValidation;
public class User
{
public string Email { get; set; }
}
public class UserValidator : AbstractValidator<User>
{
public UserValidator()
{
RuleFor(u => u.Email).MustBeEmailAddress();
}
}
Null values are ignored
var validator = new UserValidator();
// Valid, because null is ignored
var result1 = validator.Validate(new User { Email = null });
Console.WriteLine(result1.IsValid); // True
// Valid, because it's a valid email
var result2 = validator.Validate(new User { Email = "alice@company.com" });
Console.WriteLine(result2.IsValid); // True
// Invalid, because it's not a valid email
var result3 = validator.Validate(new User { Email = "not-an-email" });
Console.WriteLine(result3.IsValid); // False
Require non-null values
public class UserValidator : AbstractValidator<User>
{
public UserValidator()
{
RuleFor(u => u.Email)
.NotEmpty() // Disallow null and empty
.MustBeEmailAddress();
}
}
Links
Product | Versions 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. |
-
net9.0
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.EmailAddresses (>= 1.0.0-alpha.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-alpha.4 | 31 | 9/27/2025 |
1.0.0-alpha.3 | 65 | 9/26/2025 |
1.0.0
- Initial release with the support FluentValidation for the validation of EmailAddress value object.