Phone Number Validator
Country-aware phone validation on top of libphonenumber.
Validation is explicitly not a length comparison. libphonenumber knows which number ranges are actually assigned in each region, so +254 000 000 000 has a perfectly plausible length and is still rejected. The granular PhoneNumberValidity result distinguishes "still typing" from "wrong", which is what lets the field stay quiet until the user is actually done.
Every function here is pure and cheap — parsing a number is a few hundred microseconds, well inside a frame — so callers do not need to move validation to a background dispatcher for keystroke-level work. PhoneNumberValidator holds no state and is safe to call from any thread.
Functions
The message to show under the field for value, or null when the field should stay quiet.
Builds the complete PhoneNumberValue for nationalNumber in country: formatted forms, E.164 normalization, and validity — in one pass, so the caller never has to keep several derived strings in sync.
The live helper text under the field: "Formats live for Kenya · e.g. +254 712 345 678".