PhoneNumberBackend

Phone number metadata for phone fields: dial codes, parsing, validation and formatting.

Without a current backend, phone fields take a typed dial code and a number, and IsValidPhoneRule only checks that a dial code is present. The kotose-form-phone-backend module provides LibPhoneNumberBackend.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun countryCode(region: String): Int

The dial code of region, or 0 when it has none.

Link copied to clipboard
abstract fun formatPartial(number: String, region: String): String

The national number formatted as the user types it.

Link copied to clipboard
abstract fun isPossibleNumber(number: String, region: String): Boolean
Link copied to clipboard
abstract fun parse(phone: String, defaultRegion: String): PhoneParseResult?

A national or international number, or null when it cannot be parsed.

Link copied to clipboard
abstract fun parsePartial(phone: String, defaultRegion: String): PhonePartialResult?

An international number typed so far, from its dial code on, or null.