PosInformatique.Foundations.PhoneNumbers.FluentValidation 1.1.0

Prefix Reserved
There is a newer prerelease version of this package available.
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
                    
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.PhoneNumbers.FluentValidation" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.PhoneNumbers.FluentValidation" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.PhoneNumbers.FluentValidation" />
                    
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.PhoneNumbers.FluentValidation --version 1.1.0
                    
#r "nuget: PosInformatique.Foundations.PhoneNumbers.FluentValidation, 1.1.0"
                    
#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.PhoneNumbers.FluentValidation@1.1.0
                    
#: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.PhoneNumbers.FluentValidation&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.PhoneNumbers.FluentValidation&version=1.1.0
                    
Install as a Cake Tool

PosInformatique.Foundations.PhoneNumbers.FluentValidation

NuGet version NuGet downloads

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() for string properties
  • Validation based on the core PhoneNumber.IsValid() logic (E.164 format)
  • null values are considered valid by default (combine with NotNull() / 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 PhoneNumber value 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 Mobile is null, the rule passes.
  • If Mobile is not null, 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:

  • Mobile is not null or empty.
  • Mobile must be a valid phone number in E.164 format.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.