Laravel Postal Code Validation

Laravel Postal Code Validation

Postal code validation for multiple countries can always be a pain, but thanks to the Laravel Postal Code Validation package by Choraimy Kroonstuiver, validating postal codes is a breeze:

$this->validate($request, [
    'postal_code' => 'postal_code:NL,BE',
]);

Here’s a fluent version of the rule:

$this->validate($request, [
    'postal_code' => [
        PostalCode::forCountry('NL')->andCountry('BE'),
    ],
]);

This package supports worldwide postal code validation, enabling your forms to support multiple postal codes or single out a specific postal code based on the user’s current locale for example.

As an interesting aside, I recently found this helpful list of regular expressions from the Common Locale Data Repository (CLDR) if you’re interested in regular expression postal code validation rules for every territory in the world. Here’s a Gist of the CLDR regex rules as a PHP array available on GitHub.

To start using this package, check out the source code and readme at axlon/laravel-postal-code-validation on GitHub.


Filed in: Laravel Packages


Newsletter

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

Laravel News Partners

Laravel Jobs

Laravel Developer
San Jose, CA - Must Be Local
X3 Builders
Experienced PHP Developer
Wilmington, NC
Queensboro Shirt Company
Senior Laravel developer
Netherlands, Rotterdam
Pionect
Senior Laravel Engineer
Remote okay (must already live in USA)
Hawthorne Effect
Senior Software Engineer (Remote - Contract)
Remote
Koodi Systems
PHP Developer
Pittsburgh / Remote
Sequoia Waste Solutions
Software Developer
Eindhoven
Simac IDS