# Phone validation

`phoneNumberValidation()` checks whether a phone number is valid and returns it in national and international format, with its country and network.

phone.phpphp

```php
use IdealPostcodes\IdealPostcodes;
use IdealPostcodes\Types\PhoneNumber;

$client = IdealPostcodes::client('ak_test');
$phone = $client->phoneNumberValidation(['query' => '+44 20 7112 8019'])->result;

if ($phone instanceof PhoneNumber) {
    echo $phone->internationalFormat, ' ', $phone->country, ' ', $phone->originalCarrier?->name, PHP_EOL;
}
```

Include the country code. A UK number can start `+44`, `44` or `0044`. Your key needs phone validation enabled.

## What does it return?

A valid number returns a `PhoneNumber` with:

| Property                       | Example                                                                                                                    |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| `nationalFormat`               | `020 7112 8019`                                                                                                            |
| `internationalFormat`          | `+44 20 7112 8019`                                                                                                         |
| `isoCountry` and `isoCountry2` | `GBR` and `GB`                                                                                                             |
| `country`                      | `United Kingdom`                                                                                                           |
| `originalCarrier`              | A `Carrier` for the network the number was first assigned to, with `name` and `networkType` such as `mobile` or `landline` |

An invalid number returns an `InvalidPhoneNumber` with `valid` `false` and every other property `null`. It is not an error, so check the class before reading the formats.

## Can I find the current network?

Add `'current_carrier' => 'true'` alongside `query` to fill `currentCarrier` as well. A number can move to another network, so `originalCarrier` alone can be out of date. The extra check can be slow, depending on the network, so allow for it in your [request timeout](/docs/sdks/php/setup.md#how-do-i-set-a-request-timeout).

## What does it cost?

One lookup per request, including numbers that are invalid or fail to parse.

See [`validate`](/docs/sdks/php/endpoints/phone-number-validation.md) for the parameters and the [phone validation guide](/docs/guides/phone-validation.md) for how the checks work.
