NormalPhone 1.0.0

Normalize phone number before place it in persistent storage. Transform normal phone number to international format before show it to user.

Install-Package NormalPhone -Version 1.0.0
dotnet add package NormalPhone --version 1.0.0
<PackageReference Include="NormalPhone" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NormalPhone --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Phone number string normalization-denormalization tools

PhoneNormalizationContext context = new PhoneNormalizationContextImpl();

Assert.AreEqual("7 1112223344", context.NormalNumberFactory.make("+7 111 222-33-44"));
Assert.AreEqual("7 1112223344", context.NormalNumberFactory.make("+7 111 222 33 44"));
Assert.AreEqual("44 3811294728", context.NormalNumberFactory.make("+44 (381) 129-47-28"));
Assert.AreEqual("33 7540250047", context.NormalNumberFactory.make("+33 754 025.00.47"));

Assert.AreEqual(string.Empty, context.NormalNumberFactory.make("2.3.4.5"));
Assert.AreEqual(string.Empty, context.NormalNumberFactory.make("not a phone number"));

Assert.AreEqual("+7 912 923-56-73", context.InternationalNumberFactory.make("7 9129235673"));
Assert.AreEqual("+1 534-137-2039", context.InternationalNumberFactory.make("1 5341372039"));
Assert.AreEqual("+33 2981259365", context.InternationalNumberFactory.make("33 2981259365"));
Assert.AreEqual("+44 847 274 3614", context.InternationalNumberFactory.make("44 8472743614"));
Assert.AreEqual("+39 387 108 3726", context.InternationalNumberFactory.make("39 3871083726"));
Assert.AreEqual("+49 1115640837", context.InternationalNumberFactory.make("49 1115640837"));
Assert.AreEqual("+358 2 183783290", context.InternationalNumberFactory.make("358 2183783290"));

Assert.AreEqual(string.Empty, context.InternationalNumberFactory.make("D 238947"));
Assert.AreEqual(string.Empty, context.InternationalNumberFactory.make("is not a phone number"));

Phone number string normalization-denormalization tools

PhoneNormalizationContext context = new PhoneNormalizationContextImpl();

Assert.AreEqual("7 1112223344", context.NormalNumberFactory.make("+7 111 222-33-44"));
Assert.AreEqual("7 1112223344", context.NormalNumberFactory.make("+7 111 222 33 44"));
Assert.AreEqual("44 3811294728", context.NormalNumberFactory.make("+44 (381) 129-47-28"));
Assert.AreEqual("33 7540250047", context.NormalNumberFactory.make("+33 754 025.00.47"));

Assert.AreEqual(string.Empty, context.NormalNumberFactory.make("2.3.4.5"));
Assert.AreEqual(string.Empty, context.NormalNumberFactory.make("not a phone number"));

Assert.AreEqual("+7 912 923-56-73", context.InternationalNumberFactory.make("7 9129235673"));
Assert.AreEqual("+1 534-137-2039", context.InternationalNumberFactory.make("1 5341372039"));
Assert.AreEqual("+33 2981259365", context.InternationalNumberFactory.make("33 2981259365"));
Assert.AreEqual("+44 847 274 3614", context.InternationalNumberFactory.make("44 8472743614"));
Assert.AreEqual("+39 387 108 3726", context.InternationalNumberFactory.make("39 3871083726"));
Assert.AreEqual("+49 1115640837", context.InternationalNumberFactory.make("49 1115640837"));
Assert.AreEqual("+358 2 183783290", context.InternationalNumberFactory.make("358 2183783290"));

Assert.AreEqual(string.Empty, context.InternationalNumberFactory.make("D 238947"));
Assert.AreEqual(string.Empty, context.InternationalNumberFactory.make("is not a phone number"));

Release Notes

First version

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 111 5/19/2019