{"id":19186823,"url":"https://github.com/notus-sh/postcode_validator","last_synced_at":"2026-03-05T00:03:08.251Z","repository":{"id":52238103,"uuid":"127288378","full_name":"notus-sh/postcode_validator","owner":"notus-sh","description":"A simple postcode validator based on the Unicode CLDR project, with an optional integration with ActiveModel.","archived":false,"fork":false,"pushed_at":"2025-10-23T09:38:35.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T11:21:10.097Z","etag":null,"topics":["geography","rails","ruby","validations"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notus-sh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"open_collective":"notus-sh"}},"created_at":"2018-03-29T12:29:21.000Z","updated_at":"2025-10-23T09:37:45.000Z","dependencies_parsed_at":"2023-12-22T10:11:49.851Z","dependency_job_id":"822d66f1-3b26-44fe-8304-714663530ec6","html_url":"https://github.com/notus-sh/postcode_validator","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":"0.29268292682926833","last_synced_commit":"f53b1ff8213cd8b8d1108182b97ced807c76898e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/notus-sh/postcode_validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notus-sh%2Fpostcode_validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notus-sh%2Fpostcode_validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notus-sh%2Fpostcode_validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notus-sh%2Fpostcode_validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notus-sh","download_url":"https://codeload.github.com/notus-sh/postcode_validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notus-sh%2Fpostcode_validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30101688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T23:59:36.199Z","status":"ssl_error","status_checked_at":"2026-03-04T23:56:48.556Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["geography","rails","ruby","validations"],"created_at":"2024-11-09T11:16:49.985Z","updated_at":"2026-03-05T00:03:08.180Z","avatar_url":"https://github.com/notus-sh.png","language":"Ruby","funding_links":["https://opencollective.com/notus-sh"],"categories":[],"sub_categories":[],"readme":"# PostcodeValidator\n\n[![Unit tests](https://github.com/notus-sh/postcode_validator/actions/workflows/unit-tests.yml/badge.svg?branch=main)](https://github.com/notus-sh/postcode_validator/actions/workflows/unit-tests.yml)\n[![Gem Version](https://badge.fury.io/rb/postcode_validator.svg)](https://badge.fury.io/rb/postcode_validator)\n\nA simple postcode validator based on the Unicode CLDR project, with an optional integration with ActiveModel.\n\n## Installation\n\n`PostcodeValidator` is distributed as a gem and available on [rubygems.org](https://rubygems.org/gems/postcode_validator) so you can add it to your `Gemfile` or install it manually with:\n\n```ruby\ngem install postcode_validator\n```\n\n## Usage\n\nYou can use `PostcodeValidator` either as a stand-alone validator or integrated with ActiveModel.\n\n### Stand-alone\n\n```ruby\nrequire 'postcode_validator'\n\nvalidator = PostcodeValidator.new\n\nvalidator.valid?('98025', country: 'FR') # True\nvalidator.valid?('AB21 9BG', country: :GB) # True\nvalidator.valid?('AB21 9BG', country: :DE) # False\nvalidator.valid?('', country: 'PA') # True - Panama does not use postcodes.\n```\n\nThe `:country` option is **required**. It can be anything that respond to `to_s`.\nIf the supplied `:country` is not a valid [ISO-3166 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2), a `PostcodeValidator::Error` will be raised.\n\n### ActiveModel integration\n\n```ruby\nclass Address \u003c ActiveRecord::Base\n\n  # With a dedicated helper\n  validates_as_postcode :zipcode, country: :US\n\n  # Or through the generic `validates` class method, mixed with other validators\n  validates :post_code,\n    presence: true,\n    postcode: { allow_nil: true, country: -\u003e { |record| record.country_code } }\nend\n```\n\nThe ActiveModel validator supports the same common arguments others standard validators do (`:if`, `:unless`, `:on`, `:allow_nil`, `:allow_blank` and `:strict`).\nThe `:country` argument is **required**. It can be either a static value (anything that respond to `to_s`) or a lambda. The lambda will be called with the will be validated record as its first argument.\n\nIf the supplied `:country` is not a valid [ISO-3166 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2), the postcode validation will be skipped (It's your responsability to validate the value of `:country`).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/notus-sh/postcode_validator.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotus-sh%2Fpostcode_validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotus-sh%2Fpostcode_validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotus-sh%2Fpostcode_validator/lists"}