PosInformatique.Foundations.PhoneNumbers.FluentValidation
1.1.0
Prefix Reserved
See the version list below for details.
dotnet add package PosInformatique.Foundations.PhoneNumbers.FluentValidation --version 1.1.0
NuGet\Install-Package PosInformatique.Foundations.PhoneNumbers.FluentValidation -Version 1.1.0
<PackageReference Include="PosInformatique.Foundations.PhoneNumbers.FluentValidation" Version="1.1.0" />
<PackageVersion Include="PosInformatique.Foundations.PhoneNumbers.FluentValidation" Version="1.1.0" />
<PackageReference Include="PosInformatique.Foundations.PhoneNumbers.FluentValidation" />
paket add PosInformatique.Foundations.PhoneNumbers.FluentValidation --version 1.1.0
#r "nuget: PosInformatique.Foundations.PhoneNumbers.FluentValidation, 1.1.0"
#:package PosInformatique.Foundations.PhoneNumbers.FluentValidation@1.1.0
#addin nuget:?package=PosInformatique.Foundations.PhoneNumbers.FluentValidation&version=1.1.0
#tool nuget:?package=PosInformatique.Foundations.PhoneNumbers.FluentValidation&version=1.1.0
PosInformatique.Foundations.PhoneNumbers.FluentValidation
Introduction
This package provides FluentValidation integration for the PhoneNumber value object
from PosInformatique.Foundations.PhoneNumbers.
It adds a dedicated validator and extension method to validate that string properties contain valid phone numbers
in E.164 format, using the same parsing and validation logic as the core PhoneNumber type.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.PhoneNumbers.FluentValidation
Features
- FluentValidation integration for phone number validation
- Extension method
MustBePhoneNumber()forstringproperties - Validation based on the core
PhoneNumber.IsValid()logic (E.164 format) nullvalues are considered valid by default (combine withNotNull()/NotEmpty()when needed)- Consistent validation rules across your application
Use cases
- Validate incoming DTOs or commands that contain phone numbers as strings
- Ensure only valid E.164 phone numbers are accepted at the boundaries of your system
- Reuse the same validation logic used by the
PhoneNumbervalue object everywhere
Examples
Basic validation with MustBePhoneNumber
using FluentValidation;
public sealed class ContactDto
{
public string Name { get; set; } = default!;
public string? Mobile { get; set; }
}
public sealed class ContactDtoValidator : AbstractValidator<ContactDto>
{
public ContactDtoValidator()
{
RuleFor(x => x.Mobile)
.MustBePhoneNumber(); // Validates Mobile as an E.164 phone number (or null)
}
}
- If
Mobileisnull, the rule passes. - If
Mobileis notnull, it must be a valid phone number in E.164 format, otherwise validation fails with the default message:"'Mobile' must be a valid phone number in E.164 format."
Combine with NotNull / NotEmpty
If you want to make the phone number mandatory, combine MustBePhoneNumber() with standard FluentValidation rules:
public sealed class RequiredContactDtoValidator : AbstractValidator<ContactDto>
{
public RequiredContactDtoValidator()
{
RuleFor(x => x.Mobile)
.NotEmpty()
.MustBePhoneNumber();
}
}
This enforces:
Mobileis notnullor empty.Mobilemust be a valid phone number in E.164 format.
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 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
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.PhoneNumbers (>= 1.1.0)
-
net8.0
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.PhoneNumbers (>= 1.1.0)
-
net9.0
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.PhoneNumbers (>= 1.1.0)
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.2.0-rc.3 | 54 | 7/17/2026 |
| 1.2.0-rc.2 | 59 | 7/17/2026 |
| 1.2.0-rc.1 | 80 | 3/31/2026 |
| 1.1.0 | 127 | 3/30/2026 |
| 1.1.0-rc.3 | 84 | 3/27/2026 |
| 1.1.0-rc.2 | 86 | 1/26/2026 |
| 1.1.0-rc.1 | 87 | 1/23/2026 |
| 1.0.0 | 450 | 11/19/2025 |
| 1.0.0-rc.4 | 417 | 11/19/2025 |
| 1.0.0-rc.3 | 404 | 11/18/2025 |
| 1.0.0-rc.2 | 397 | 11/18/2025 |
| 1.0.0-rc.1 | 396 | 11/18/2025 |
1.0.0
- Initial release with the support FluentValidation for the validation of PhoneNumber value object.