PhoneRule

interface PhoneRule { calling_code?: string; national_prefix?: string; masks?: { start?: string; mask: string }[]; pattern: string; example?: string; }

How a phone number is written as it is typed, checked, and turned into E.164 (+14155552671), the form an order takes it in. The check is loose on purpose: the order API validates the number itself, so a pattern only refuses what is clearly not a phone number.

The example is the US's: every US number is written in one shape, so it has one mask, and no start.

Example

CODE
{
  "calling_code": "1",
  "national_prefix": "1",
  "masks": [{ "mask": "(###) ###-####" }],
  "pattern": "^[0-9]{10,11}$",
  "example": "(201) 555-0123"
}

Properties

calling_code: string

The ITU calling code, without the +. Absent for Argentina, whose mobile numbers need a conversion: POST /v1/validate makes it, from what was typed.

national_prefix: string

Dialled before a national number inside the country, and shown before the mask.

masks: { start?: string; mask: string }[]

How the number is shown while typed: # is one digit, (###) ###-####. The first mask whose start (a regex tested against the start of the digits typed) matches is used; the last has no start and is the default.

pattern: string

A regular expression matched against the digits typed, in national form, with or without the national prefix.

example: string

A real number, in national form: the one the invalid message shows.