NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Validate place ids and coordinates in your own requests:

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:

KeyUsed whenensk
place_idValidPlaceId failsThe :attribute must be a valid Google Place ID.Pole :attribute musí obsahovať platné Google Place ID.
coordinatesValidCoordinates: not a recognisable pairThe :attribute must be a valid latitude/longitude pair.Pole :attribute musí obsahovať platnú dvojicu zemepisnej šírky a dĺžky.
latitudeValidCoordinates: latitude out of rangeThe :attribute latitude must be between -90 and 90.Zemepisná šírka v poli :attribute musí byť medzi -90 a 90.
longitudeValidCoordinates: longitude out of rangeThe :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:

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

By donating, you agree to our donation terms.

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.