Documentation
¶
Overview ¶
Package phone parses region-specific phone numbers into canonical E.164 values. Only importers of this package compile the phone numbering metadata.
Index ¶
Constants ¶
const MaxInputBytes = 100
MaxInputBytes bounds the original input before trimming or parsing.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type E164 ¶
type E164 struct {
// contains filtered or unexported fields
}
E164 is a validated canonical phone number. Construct it with Parse. The zero value is absent, and does not represent a valid phone number.
func Parse ¶
Parse validates national or international input for the selected region and normalizes it to E.164. Empty input rejects. Optionality and allowed regions belong to the caller. Failures match fault.Invalid and never include input. Example: number, err := phone.Parse(countries.Code("MY"), "012-345 6789", phone.Options{}).
type ExtensionPolicy ¶
type ExtensionPolicy uint8
ExtensionPolicy controls extensions, which E.164 cannot represent.
const ( // RejectExtensions rejects any parsed extension and is the default policy. RejectExtensions ExtensionPolicy = iota // DiscardExtensions explicitly permits losing the parsed extension. DiscardExtensions )
type Options ¶
type Options struct {
// Extensions controls whether an extension rejects or is explicitly discarded.
Extensions ExtensionPolicy
}
Options declares parsing policy. Its zero value rejects extensions.