Soenneker.Utils.Test.PhoneNumber
4.0.272
Prefix Reserved
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
<PackageReference Include="Soenneker.Utils.Test.PhoneNumber" Version="4.0.272" />
<PackageVersion Include="Soenneker.Utils.Test.PhoneNumber" Version="4.0.272" />
<PackageReference Include="Soenneker.Utils.Test.PhoneNumber" />
paket add Soenneker.Utils.Test.PhoneNumber --version 4.0.272
#r "nuget: Soenneker.Utils.Test.PhoneNumber, 4.0.272"
#:package Soenneker.Utils.Test.PhoneNumber@4.0.272
#addin nuget:?package=Soenneker.Utils.Test.PhoneNumber&version=4.0.272
#tool nuget:?package=Soenneker.Utils.Test.PhoneNumber&version=4.0.272
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 | Versions 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. |
-
net10.0
- Soenneker.Utils.Libphonenumber (>= 4.0.222)
- Soenneker.Utils.Random (>= 4.0.130)
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 |
Update dependency Soenneker.Utils.Random to 4.0.130 (#816)