AfterShip/phone ? reverse-engineered prompt
Reverse engineered prompt
Build me a small TypeScript phone number utility that takes a phone number and, optionally, a country, then validates it and reformats it into E.164. I want it to handle common messy user input like spaces, parentheses, and dashes, and return a simple result that says whether the number is valid, plus the normalized phone number and detected country info when it works.
It should default to treating numbers as US or Canada when no country is given, but also support countries passed in as ISO 2 or ISO 3 codes. Please include the option to check mobile prefixes by default, with a way to turn that off, and a stricter mode that disables trunk code guessing. If a number is invalid, it should return a consistent empty result instead of throwing.
Also add a few usage examples and tests for the common cases, like US, Canada, Hong Kong, and UK numbers, so I can see how it behaves.
Are you gonna build this?
make sure you review the code using coderabbit