Soenneker.Utils.Libphonenumber
4.0.245
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.Libphonenumber --version 4.0.245
NuGet\Install-Package Soenneker.Utils.Libphonenumber -Version 4.0.245
<PackageReference Include="Soenneker.Utils.Libphonenumber" Version="4.0.245" />
<PackageVersion Include="Soenneker.Utils.Libphonenumber" Version="4.0.245" />
<PackageReference Include="Soenneker.Utils.Libphonenumber" />
paket add Soenneker.Utils.Libphonenumber --version 4.0.245
#r "nuget: Soenneker.Utils.Libphonenumber, 4.0.245"
#:package Soenneker.Utils.Libphonenumber@4.0.245
#addin nuget:?package=Soenneker.Utils.Libphonenumber&version=4.0.245
#tool nuget:?package=Soenneker.Utils.Libphonenumber&version=4.0.245
Soenneker.Utils.Libphonenumber
Lazily provides libphonenumber-csharp's PhoneNumberUtil for parsing, validating, and formatting international phone numbers.
Installation
dotnet add package Soenneker.Utils.Libphonenumber
Quick start
using Soenneker.Utils.Libphonenumber.Registrars;
services.AddLibphonenumberUtilAsSingleton();
Then inject ILibphonenumberUtil wherever you need it.
Parse, validate, and format
using PhoneNumbers;
PhoneNumberUtil phoneNumbers = await libphonenumberUtil.Get(cancellationToken);
try
{
PhoneNumber number = phoneNumbers.Parse("(212) 555-0100", "US");
if (phoneNumbers.IsValidNumber(number))
{
string e164 = phoneNumbers.Format(number, PhoneNumberFormat.E164);
// +12125550100
}
}
catch (NumberParseException)
{
// The input could not be interpreted as a phone number.
}
Pass an ISO 3166-1 alpha-2 region such as "US" when parsing a national number. For an input
already beginning with + and a country calling code, the region can be null. Parsing only
interprets the text; call IsPossibleNumber or IsValidNumber when validity matters.
Get lazily returns the shared PhoneNumberUtil supplied by libphonenumber-csharp. Cache the
returned reference within an operation if you need it repeatedly. The cancellation token applies
while obtaining the lazy value; it does not affect later synchronous parsing or formatting calls.
The scoped registrar is available when the wrapper must follow a scope, but the underlying
libphonenumber instance remains shared. Let dependency injection dispose the wrapper; callers do
not own the returned PhoneNumberUtil.
| 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
- libphonenumber-csharp (>= 9.0.40)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Soenneker.Utils.AsyncSingleton (>= 4.0.851)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Utils.Libphonenumber:
| Package | Downloads |
|---|---|
|
Soenneker.Validators.Phone.Possible
A validation module checking if a given phone number is possible |
|
|
Soenneker.Phone.Util
Parses, validates, and formats phone numbers as E.164 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.249 | 79 | 9/29/2026 |
| 4.0.248 | 57 | 9/29/2026 |
| 4.0.247 | 99 | 9/25/2026 |
| 4.0.246 | 71 | 9/25/2026 |
| 4.0.245 | 100 | 9/24/2026 |
| 4.0.244 | 73 | 9/24/2026 |
| 4.0.243 | 71 | 9/24/2026 |
| 4.0.242 | 343 | 9/16/2026 |
| 4.0.241 | 132 | 9/16/2026 |
| 4.0.240 | 147 | 9/15/2026 |
| 4.0.238 | 247 | 9/13/2026 |
| 4.0.237 | 134 | 9/12/2026 |
| 4.0.235 | 183 | 9/10/2026 |
| 4.0.234 | 165 | 9/8/2026 |
| 4.0.233 | 149 | 9/7/2026 |
| 4.0.232 | 101 | 9/7/2026 |
| 4.0.231 | 198 | 9/4/2026 |
| 4.0.230 | 135 | 9/4/2026 |
| 4.0.228 | 135 | 9/4/2026 |
| 4.0.226 | 181 | 9/3/2026 |
Update dependency Soenneker.Utils.AsyncSingleton to 4.0.851 (#829)