Skip to main content
cngx-src documentation

CngxPhoneMetadata

Interface

projects/forms/input/phone-metadata.ts

Import#

import { CngxPhoneMetadata } from '@cngx/forms/input'

Description#

Strategy contract that resolves a phone number's line type from its region and national subscriber digits.

nationalDigits is the subscriber number with the country dial-code digits already stripped - CngxPhoneInput owns that extraction, so an adapter never sees the +49 prefix and can hand the digits straight to a metadata library. The default registered on CNGX_PHONE_METADATA returns 'unknown', which keeps CngxPhoneInput's length-based mask alternation unchanged; a consumer who needs prefix-accurate detection provides an adapter backed by real numbering metadata (e.g. libphonenumber-js), which stays in the consumer's dependency graph, never cngx's.

formatAsYouType / isValid are reserved for a later display-formatting pass and are intentionally not declared yet, so the contract ships as a single load-bearing method rather than an empty surface.

Index#

Methods

Methods#

lineType#"mobile" | "fixedLine" | "unknown"
lineType(region: string, nationalDigits: string)

Resolves the line type for nationalDigits in region. Return 'unknown' when the prefix is not yet decisive so the caller keeps its length-based fallback.

Must be a pure function of its two arguments: CngxPhoneInput reads it inside a computed(), so any internal state or side effect would taint that derivation and is unsupported.

@paramregionstring
@paramnationalDigitsstring