PHP code example of axlon / laravel-postal-code-validation

1. Go to this page and download the library: Download axlon/laravel-postal-code-validation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

axlon / laravel-postal-code-validation example snippets


'providers' => [
   ...
   Axlon\PostalCodeValidation\ValidationServiceProvider::class,
   ...
],

$app->register(Axlon\PostalCodeValidation\ValidationServiceProvider::class);

'postal_code' => 'postal_code:NL,DE,FR,BE'

'billing.country' => '' => 'nullable|string|max:2',
'shipping.postal_code' => 'postal_code_with:billing.country,shipping.country'

'postal_code' => [
    PostalCode::for('NL')->or('BE'),
],

'billing.country' => '' => 'nullable|string|max:2',
'shipping.postal_code' => [
    PostalCode::with('billing.country')->or('shipping.country')
],

'postal_code' => 'Your message here',
'postal_code_with' => 'Your message here',

PostalCodes::passes($country, $postalCode); // returns a boolean

PostalCodes::override('country', '/your pattern/');

// You can also pass overrides as an array

PostalCodes::override([
    'country 1' => '/pattern 1/',
    'country 2' => '/pattern 2/',
]);