# laravel-rust-phone

> Rust port of propaganistas/laravel-phone: Keep the number your customer typed. Store a consistent number for lookup.

- Package: laravel-rust-phone (Laravel for Rust, alpha), crates: `laravel-rust-phone`, `laravel-rust-phone-core`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-phone), [crates.io](https://crates.io/crates/laravel-rust-phone/0.1.0), [docs.rs](https://docs.rs/laravel-rust-phone/0.1.0), [Changelog](https://oss.bowerbird.si/phone/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-phone/blob/c3aec2c3f7375e75853ae6a5ef0d1160cd10904d/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-phone/blob/c3aec2c3f7375e75853ae6a5ef0d1160cd10904d/SECURITY.md)
- Based on: [Laravel-Phone](https://github.com/Propaganistas/Laravel-Phone): The package this ports: parsing, validation rules, formatting and model casts, following version 6.1.0.; [phonenumbers-rs](https://github.com/MasonLyons/phonenumbers-rs): Phone number parsing and formatting in Rust (version 0.1.2).; [Google libphonenumber](https://github.com/google/libphonenumber): The numbering-plan data (version 9.0.44).
- PHP parity: full (36 covered, 15 diverged, 0 planned of 51 abilities; 179 fixtures; follows propaganistas/laravel-phone 6.1.0; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/phone/
- Documentation: https://oss.bowerbird.si/phone/docs.md

Accept local numbers with a country hint and international numbers with a calling code. Use E.164 for consistent lookup and keep the original spelling when you need to show what the customer entered.

```shell
cargo add laravel-rust-phone
```

- **Validate request fields.** Use `PhoneRule` with a companion country field. Restrict accepted countries or number types when a form has specific requirements.
- **Choose how numbers are stored.** Use `E164PhoneNumber` for canonical storage or `RawPhoneNumber` to preserve the submitted text.
- **Check behavior against PHP.** The Rust suite runs 179 fixtures generated by Laravel Phone 6.1.0. The parity matrix records intentional differences.

### Normalize a Belgian number

Supply the country for national input, then format the same number for storage or display.

```rust
use laravel_rust_phone::{Error, phone};

fn main() -> Result<(), Error> {
    let number = phone("0470 12 34 56").with_countries(["BE"]);

    assert!(number.is_valid());
    assert_eq!(number.format_e164()?, "+32470123456");
    assert_eq!(number.format_international()?, "+32 470 12 34 56");
    assert_eq!(number.format_national()?, "0470 12 34 56");

    Ok(())
}
```
