Skip to main content
cngx-src documentation

withPhonePatterns

Functionforms/input

projects/forms/input/input-config.ts

Description#

Adds or overrides phone mask patterns keyed by region code.
Reach for it when a cngxInputMask="phone" / "phone:<REGION>" needs a region the library does not ship, or to override one it does.

  • Built-in regions: ~45 ISO 3166-1 alpha-2 keys across Europe, the Americas, East Asia, and Oceania (UK kept as a back-compat alias of GB).
  • Regions whose landline and mobile national-number lengths differ ship |-separated landline+mobile alternates picked by length; uniform-length plans ship a single pattern. Masks are coarse approximations, not validators - reach for libphonenumber-js when you need real validation.
  • Consumer entries merge per key onto the built-ins and win on collision.
  • Resolved as { ...PHONE_PATTERNS, ...config.phonePatterns }[region], falling back to US when the region is absent.
  • Region comes from phone:<REGION> or LOCALE_ID.
  • Pattern tokens: 0 = required digit, literals pass through.
provideInputConfig(withPhonePatterns({ LI: '+000 000 00 00' }));
// <input cngxInputMask="phone:LI" />

Signature#

withPhonePatterns(patterns: Record)

Parameters#

@parampatternsRecord

Returns#

InputConfigFeature