Soenneker.Utils.Test.PhoneNumber 4.0.272

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.Test.PhoneNumber --version 4.0.272
                    
NuGet\Install-Package Soenneker.Utils.Test.PhoneNumber -Version 4.0.272
                    
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="Soenneker.Utils.Test.PhoneNumber" Version="4.0.272" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Test.PhoneNumber" Version="4.0.272" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Test.PhoneNumber" />
                    
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 Soenneker.Utils.Test.PhoneNumber --version 4.0.272
                    
#r "nuget: Soenneker.Utils.Test.PhoneNumber, 4.0.272"
                    
#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 Soenneker.Utils.Test.PhoneNumber@4.0.272
                    
#: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=Soenneker.Utils.Test.PhoneNumber&version=4.0.272
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Test.PhoneNumber&version=4.0.272
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.Test.PhoneNumber

Generates random 10-digit test candidates that pass libphonenumber validation for a region.

Installation

dotnet add package Soenneker.Utils.Test.PhoneNumber

Usage

using Soenneker.Utils.Test.PhoneNumber;

string phoneNumber = TestPhoneNumberUtil.GetRandomValidPhoneNumber("US");

// Example shape: "3125550187"

The region defaults to "US" when omitted. The returned value contains exactly ten digits with no country calling code or formatting characters.

How generation succeeds or fails

The utility generates up to 100 ten-digit candidates, parses each one with libphonenumber using the requested default region, and returns the first candidate for which IsValidNumberForRegion is true. Parse failures are skipped. If no candidate succeeds—including for an invalid or incompatible region—it throws InvalidOperationException.

Because every candidate is ten digits, this helper is most reliable for regions whose national numbers can have that length, such as NANP regions. It is not a general international phone-number generator.

Test-data safety

Libphonenumber validation checks numbering-plan metadata; it does not prove that a number is unassigned or reserved for examples. A generated value may belong to a real person or organization. Do not call it, text it, persist it as a trusted fixture, or use it in tests that contact external providers.

Generation uses the package's ordinary random utility and is not deterministic or cryptographically secure. Use explicit reserved example numbers when reproducibility or guaranteed non-delivery matters.

Call the static method directly; no dependency-injection registration is required.

Product Compatible and additional computed target framework versions.
.NET 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
4.0.273 0 8/31/2026
4.0.272 0 8/31/2026
4.0.271 0 8/30/2026
4.0.270 0 8/30/2026
4.0.269 25 8/30/2026
4.0.268 41 8/30/2026
4.0.267 40 8/30/2026
4.0.266 37 8/30/2026
4.0.265 37 8/29/2026
4.0.264 44 8/29/2026
4.0.263 40 8/29/2026
4.0.262 42 8/29/2026
4.0.261 73 8/26/2026
4.0.260 79 8/26/2026
4.0.259 129 8/15/2026
4.0.258 89 8/12/2026
4.0.257 94 8/12/2026
4.0.256 93 8/9/2026
4.0.255 92 8/8/2026
4.0.254 125 8/3/2026
Loading failed

Update dependency Soenneker.Utils.Random to 4.0.130 (#816)