---
title: "Validation rules — Google Places for Laravel | Roundly"
description: "Drop-in Laravel rules that check a place id or a latitude/longitude pair is well-formed before you call Google — messages in English and Slovak."
url: https://roundly-consulting.com/open-source/docs/google-places-for-laravel/validation-rules
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Google Places for Laravel](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)

# Validation rules

Validate place ids and coordinates in your own requests:

```php
use RoundlyConsulting\GooglePlaces\Rules\ValidCoordinates;
use RoundlyConsulting\GooglePlaces\Rules\ValidPlaceId;

$request->validate([
    'place' => ['required', new ValidPlaceId],
    'point' => ['required', new ValidCoordinates], // Location, [lat, lng], or "lat,lng"
]);
```

- ValidPlaceId — a string of 6–512 URL-safe base64 characters (letters, digits, \_ and -), e.g. ChIJN1t\_tDeuEmsRUsoyG83frY4.
- ValidCoordinates — accepts a Location, a \[lat, lng\] array, a keyed array (lat/lng or latitude/longitude) or a “lat,lng” string; latitude must be within −90…90 and longitude within −180…180.

Both rules check format only — they never call Google, so they cost nothing.

## Messages and translations

The messages come from the package’s google-places::validation translation file, in English and Slovak. They follow the app locale, and :attribute becomes the field’s display name (or your validation.attributes entry), as with Laravel’s own rules:

| Key | Used when | en | sk |
| --- | --- | --- | --- |
| `place_id` | ValidPlaceId fails | The :attribute must be a valid Google Place ID. | Pole :attribute musí obsahovať platné Google Place ID. |
| `coordinates` | ValidCoordinates: not a recognisable pair | The :attribute must be a valid latitude/longitude pair. | Pole :attribute musí obsahovať platnú dvojicu zemepisnej šírky a dĺžky. |
| `latitude` | ValidCoordinates: latitude out of range | The :attribute latitude must be between -90 and 90. | Zemepisná šírka v poli :attribute musí byť medzi -90 a 90. |
| `longitude` | ValidCoordinates: longitude out of range | The :attribute longitude must be between -180 and 180. | Zemepisná dĺžka v poli :attribute musí byť medzi -180 a 180. |

To change the wording or add a language, publish the files and edit them in lang/vendor/google-places:

```bash
php artisan vendor:publish --tag="google-places-translations"
```

Laravel’s per-request custom messages still work as well. When you call a rule’s validate() directly, your closure receives the message already translated, with :attribute still in it.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/google-places-for-laravel.md)
