{"id":13828317,"url":"https://github.com/axlon/laravel-postal-code-validation","last_synced_at":"2025-05-14T13:07:15.066Z","repository":{"id":40572014,"uuid":"160712053","full_name":"axlon/laravel-postal-code-validation","owner":"axlon","description":"Worldwide postal code validation for Laravel and Lumen","archived":false,"fork":false,"pushed_at":"2025-03-25T20:33:58.000Z","size":163,"stargazers_count":378,"open_issues_count":1,"forks_count":30,"subscribers_count":3,"default_branch":"3.x","last_synced_at":"2025-04-14T01:49:09.875Z","etag":null,"topics":["laravel","laravel-package","lumen","postal-code","validation","zip-code"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axlon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-06T17:58:43.000Z","updated_at":"2025-04-10T09:24:48.000Z","dependencies_parsed_at":"2024-01-29T00:07:53.626Z","dependency_job_id":"c98cb95f-2a32-4734-8087-0e1037f101cb","html_url":"https://github.com/axlon/laravel-postal-code-validation","commit_stats":{"total_commits":126,"total_committers":10,"mean_commits":12.6,"dds":0.5634920634920635,"last_synced_commit":"b4cd64b0d3358c42d7805370c5f9ab2f2f411e81"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlon%2Flaravel-postal-code-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlon%2Flaravel-postal-code-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlon%2Flaravel-postal-code-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axlon%2Flaravel-postal-code-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axlon","download_url":"https://codeload.github.com/axlon/laravel-postal-code-validation/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149958,"owners_count":22022851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-package","lumen","postal-code","validation","zip-code"],"created_at":"2024-08-04T09:02:41.065Z","updated_at":"2025-05-14T13:07:10.037Z","avatar_url":"https://github.com/axlon.png","language":"PHP","readme":"# Laravel Postal Code Validation\nWorldwide postal code validation for Laravel, based on Google's Address Data Service.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/axlon/laravel-postal-code-validation/actions\"\u003e\n        \u003cimg src=\"https://github.com/axlon/laravel-postal-code-validation/workflows/tests/badge.svg\" alt=\"Build status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/axlon/laravel-postal-code-validation\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/dt/axlon/laravel-postal-code-validation\" alt=\"Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/axlon/laravel-postal-code-validation/releases\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/v/axlon/laravel-postal-code-validation\" alt=\"Latest version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/l/axlon/laravel-postal-code-validation\" alt=\"License\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n    - [Lumen](#lumen)\n- [Usage](#usage)\n    - [Available rules](#available-rules)\n    - [Fluent API](#fluent-api)\n    - [Adding an error message](#adding-an-error-message)\n    - [Manually validating](#manually-validating)\n    - [Overriding rules](#overriding-rules)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n## Requirements\nThis package has the following requirements:\n\n- PHP 7.2 or higher\n- Laravel (or Lumen) 5.5 or higher\n\n| Laravel / Lumen version | Package version |\n|-------------------------|-----------------|\n| 5.1 - 5.4               | [2.x](https://github.com/axlon/laravel-postal-code-validation/tree/2.x) |\n| 5.5 and greater         | 3.x             |\n\n## Installation\nYou can install this package with Composer, by running the command below:\n\n```bash\ncomposer require axlon/laravel-postal-code-validation\n```\n\nIf you have package discovery enabled, that's it, continue to the [usage](#usage) section. If you want to register the\npackage manually, you can do this by adding the following line to your `config/app.php` file:\n\n```php\n'providers' =\u003e [\n   ...\n   Axlon\\PostalCodeValidation\\ValidationServiceProvider::class,\n   ...\n],\n```\n\n### Lumen\nIf you are using Lumen, register the package by adding the following line to your `bootstrap/app.php` file:\n\n```php\n$app-\u003eregister(Axlon\\PostalCodeValidation\\ValidationServiceProvider::class);\n```\n\n## Usage\nPostal code validation perfectly integrates into your Laravel application, you can use it just like you would any\nframework validation rule.\n\n### Available rules\nThis package adds the following validation rules:\n\n#### postal_code:foo,bar,...\nThe field under validation must be a valid postal code in at least one of the given countries. Arguments must be\ncountries in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.\n\n```php\n'postal_code' =\u003e 'postal_code:NL,DE,FR,BE'\n```\n\n#### postal_code_with:foo,bar,...\nThe field under validation must be a postal code in at least one of the countries in the given fields _only if_ at least\none of the specified fields is present.\n\n```php\n'billing.country' =\u003e 'required|string|max:2',\n...\n'shipping.country' =\u003e 'nullable|string|max:2',\n'shipping.postal_code' =\u003e 'postal_code_with:billing.country,shipping.country'\n```\n\n### Fluent API\nIf you prefer using a fluent object style over string based rules, that's also available:\n\n```php\n'postal_code' =\u003e [\n    PostalCode::for('NL')-\u003eor('BE'),\n],\n```\n\nThe same goes for the `postal_code_with` rule:\n\n```php\n'billing.country' =\u003e 'required|string|max:2',\n...\n'shipping.country' =\u003e 'nullable|string|max:2',\n'shipping.postal_code' =\u003e [\n    PostalCode::with('billing.country')-\u003eor('shipping.country')\n],\n```\n\n### Adding an error message\nTo add a meaningful error message, add the following lines to `resources/lang/{your language}/validation.php`:\n\n```php\n'postal_code' =\u003e 'Your message here',\n'postal_code_with' =\u003e 'Your message here',\n```\n\nThe following placeholders will be automatically filled for you:\n\nPlaceholder | Description\n------------|------------\n:attribute  | The name of the field that was under validation\n:countries  | The countries that were validated against (e.g. `NL, BE`)*\n:examples   | Examples of allowed postal codes (e.g. `1234 AB, 4000`)*\n\n*The `:countries` and `:examples` placeholders may be empty if no valid countries are passed.\n\n### Manually validating\nIf you want to validate postal codes manually outside of Laravel's validation system, you can call the validator\ndirectly, like so:\n\n```php\nPostalCodes::passes($country, $postalCode); // returns a boolean\n```\n\n### Overriding rules\nDepending on your use case you may want to override the patterns used to validate postal codes for a country. You can do\nthis by adding the code below in a central place in your application (e.g. a service provider):\n\n```php\nPostalCodes::override('country', '/your pattern/');\n\n// You can also pass overrides as an array\n\nPostalCodes::override([\n    'country 1' =\u003e '/pattern 1/',\n    'country 2' =\u003e '/pattern 2/',\n]);\n```\n\n**Important**: If you believe there is a bug in one of the patterns that this package ships with, please create an\n[issue](https://github.com/axlon/laravel-postal-code-validation/issues/new) in the issue tracker.\n\n## Changelog\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n- [Choraimy Kroonstuiver](https://github.com/axlon)\n- [All contributors](https://github.com/axlon/laravel-postal-code-validation/contributors)\n\n## License\nThis open-source software is licenced under the [MIT license](LICENSE.md). This software contains code generated from\nGoogle's Address Data Service, more information on this service can be found\n[here](https://github.com/google/libaddressinput/wiki/AddressValidationMetadata).\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxlon%2Flaravel-postal-code-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxlon%2Flaravel-postal-code-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxlon%2Flaravel-postal-code-validation/lists"}