Laravel Phone Rust
Phone number validation, formatting and E.164 database columns for Laravel for Rust.
cargo add laravel-phone-rust
Try it
A number and the country to read a national number in, such as NL, or several separated by commas.
Valid, a mobile number from NL.
- E.164, as the database column stores it
- +31612345678
- International
- +31 6 12345678
- National
- 06 12345678
- RFC 3966
- tel:+31-6-12345678
- Dialed from NL
- 06 12345678
- Dialed from US
- 011 31 6 12345678
- PhoneRule for these countries
- passes
- The same rule, mobile only
- passes
Validity follows libphonenumber's data. Try a number from your own country in the demo above.
What it does
-
Parse in a country
A number with a + reads as written. A national number reads in each country you name, and the first one it is valid in wins.
-
A validation rule
PhoneRule checks the country, the kind of line and a country field next to the number, with a message ready to show.
-
E.164 columns
A Phone field on a model stores +31612345678 and reads back the same, in JSON too.
-
Every format
E.164, international, national and RFC 3966, plus how to dial the number from another country or from a phone.
Hi, I'm Mischa. I've been shipping products and building ventures for over a decade. First exit at 25, second at 30. Now Partner & CPO at Ryde Ventures, an AI venture studio in Amsterdam. Currently shipping Stagent, TAP and Steddle. I write about what I learn along the way. More about me.
You might also enjoy: Why I built Laravel TOON (and how it saves 60% on LLM tokens).