Laravel Postcodes: A Service Wrapper Around

Laravel Postcodes: A Service Wrapper Around

Laravel Postcodes is a package by Steve McDougall that provides a validation rule and macro for validating post codes. The package uses the service—a free and open-source API—for looking up geocoded UK postcodes.

There are three ways to interact with postcodes using this package. First, you can use the provided validation rule:

use JustSteveKing\LaravelPostcodes\Rules\Postcode;

$this->validate($request, [
    ‘postcode’ => [
        new Postcode()

Second, you can use the provided macro:

$this->validate($request, [
    ‘postcode’ => [

Third, this package defines a service for interacting with the API directly:

use JustSteveKing\LaravelPostcodes\Service\PostcodeService;


You can learn more about this package, get full installation instructions, and view the source code on GitHub at JustSteveKing/LaravelPostcodes.

This package was submitted to our Laravel News Links section. This section is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in: News


Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

PHP Data Engineer
Remote (US)
Software Developer
Remote (US & Canada)
Backend Software Engineer
Remote (UTC +/- 5)
Remote (Overlap w/ Continental US Time Zones)
Senior Backend Engineer
64 Robots
Senior Laravel Developer
Atlanta, GA
Helium LLC
Full-Stack Developer (JS - Vue.js, PHP - Laravel)
US Remote / Telecommute
TTEC Digital