---
title: "Validate an emergency or short phone number in C#"
url: https://recursiveai.org/onecontact/cookbook/validate-short-phone-number/
description: "Validate an emergency or short phone number in C#: runnable OneContact example, real output and regional or ambiguity rules."
version: "1.0.0"
---

# Validate an emergency or short phone number in C#

**OneContact** is a free, open-source contact data library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies, no network access.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneContact) · [GitHub](https://github.com/recursive-ai-oss/onecontact-csharp) · [Docs](https://recursiveai.org/onecontact/docs/) · [Download example (.zip)](https://recursiveai.org/onecontact/cookbook/validate-short-phone-number/validate-short-phone-number.zip)

Short numbers like 911 or 112 need a separate check for each country, not the check for a full phone number.

```shell
dotnet add package RecursiveAI.OneContact
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneContact;
using RecursiveAI.OneContact.Phones;
var info = ShortNumberInfo.Default;
var region = Region.Parse("US");
var number = PhoneNumber.Parse("911", region);
Console.WriteLine(info.IsValidForRegion(
    number, region));
Console.WriteLine(info.IsEmergencyNumber(
    "911", region));
```

```text
True
True
```

These checks read bundled metadata; they do not test live service availability or emergency routing.

Unzip [the example](https://recursiveai.org/onecontact/cookbook/validate-short-phone-number/validate-short-phone-number.zip), then `dotnet run`.

## Variations

Compare an exact emergency match with the prefix-matching metadata rule:

```csharp
using RecursiveAI.OneContact;
using RecursiveAI.OneContact.Phones;
var info = ShortNumberInfo.Default;
var region = Region.Parse("US");
Console.WriteLine(
    info.IsEmergencyNumber(
        "911123", region));
Console.WriteLine(
    info.ConnectsToEmergencyNumber(
        "911123", region));
Console.WriteLine(
    info.IsEmergencyNumber(
        "+911", region));
```

```text
False
True
False
```

## Related recipes

- [Validate a complete phone number](https://recursiveai.org/onecontact/cookbook/validate-phone-number/)

## The short answer

Use `ShortNumberInfo.Default` with an explicit region. `IsValidForRegion` checks a parsed short number against that region’s short-code metadata. `IsEmergencyNumber` checks the supplied text against its emergency-number patterns. The example prints `True` for both checks on `911` in the US.

These are metadata answers, not calls to a network. They cannot confirm that a device has service, that a route is available, or that anyone will answer. The [short-number documentation](https://recursiveai.org/onecontact/docs/phones/#short-numbers) defines the exact checks, including how region, length and emergency prefixes affect them.

## How can I validate phone numbers in C#?

Choose the validator for the kind of number you accept. A short-code field should use `ShortNumberInfo`, not an ordinary full-length phone-number check or a fixed digit count. The snippet parses the input with its region to provide a `PhoneNumber` value, then asks the short-number metadata whether it is valid there.

Keep possibility and validity separate. A short number is possible when its length is one listed by a short-number description in the region. It is valid when it is possible and matches the short-code description. A length check can therefore pass while validity fails. Neither result establishes ownership or confirms that the code is currently usable by a specific subscriber.

## How do I validate an emergency short phone number in C#?

Use the text-based `IsEmergencyNumber` method when the question is whether the complete supplied text matches an emergency pattern. Keep the region explicit even when the input looks familiar. Region-specific methods answer false when a parsed number’s calling code does not match the region being queried.

Do not prepend a plus sign to make emergency input look international. The documented emergency check rejects a leading plus sign. Surrounding punctuation is ignored, but that is not a reason to remove all punctuation yourself before checking: changing the input can change what question is being answered. Preserve the raw text if you need to explain the result to a user.

The variation also calls `ConnectsToEmergencyNumber`. Despite its name, this is another metadata-pattern operation, not a connection attempt. It allows extra digits after an emergency prefix except in Brazil, Chile and Nicaragua. That distinction explains why `911123` returns false for the exact US check and true for the prefix check. Never use the result as evidence that calling that string will succeed.

## Can you provide a regex to validate phone numbers?

A single expression is the wrong level of abstraction for regional short-code rules. You would need to choose regional length and number patterns and maintain their updates, as well as decide whether you want an exact emergency check or a prefix check. The library already exposes those decisions through named operations over its bundled metadata.

If your form only accepts short codes, keep that purpose visible in the field design. Do not reject a code solely because it lacks the length of a normal subscriber number. Conversely, do not accept arbitrary short strings just because they have a plausible length. Use `IsPossibleForRegion` for the length question and `IsValidForRegion` for the full metadata question, and retain an unverified state for any real-world availability claim.
