{"id":28471803,"url":"https://github.com/peburrows/validates_as_postal_code","last_synced_at":"2025-07-01T22:30:47.956Z","repository":{"id":66505429,"uuid":"104202","full_name":"peburrows/validates_as_postal_code","owner":"peburrows","description":"Rails plugin to validate postal codes from around the world. validates_as_postal_code","archived":false,"fork":false,"pushed_at":"2010-11-26T07:43:46.000Z","size":116,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T11:08:50.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peburrows.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-01-09T16:51:48.000Z","updated_at":"2024-07-02T14:02:50.000Z","dependencies_parsed_at":"2023-02-20T05:25:18.632Z","dependency_job_id":null,"html_url":"https://github.com/peburrows/validates_as_postal_code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peburrows/validates_as_postal_code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fvalidates_as_postal_code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fvalidates_as_postal_code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fvalidates_as_postal_code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fvalidates_as_postal_code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peburrows","download_url":"https://codeload.github.com/peburrows/validates_as_postal_code/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fvalidates_as_postal_code/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263046053,"owners_count":23405125,"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":[],"created_at":"2025-06-07T11:08:55.939Z","updated_at":"2025-07-01T22:30:47.940Z","avatar_url":"https://github.com/peburrows.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Usage\n\n### validates\\_as\\_postal\\_code\n\u003cpre\u003e\u003ccode\u003e\n  # when :country parameter is a String,\n  # validate as a postal code from a specific country\n  validates_as_postal_code :postal_code, :country =\u003e 'United States'\n\n  # when :country parameter is a Symbol\n  # validate depending on the value of a specific field in the model\n  validates_as_postal_code :postal_code, :country =\u003e :cardholder_country\n\u003c/code\u003e\u003c/pre\u003e\n\n### Country Lists\n\nEach of the following return a list of countries with the following information for each country:\n*name*, *region*, *continent*, *ISO numeric code*, *ISO 2-letter code*, *ISO 3-letter code*, *postal code regular expression*\n\n\u003cpre\u003e\u003ccode\u003e\n  VST::Validations::Addresses.north_america\n  # =\u003e [\n  #       { :name =\u003e 'Canada',\n  #         :numeric =\u003e '124',\n  #         :alpha2 =\u003e 'CA',\n  #         :alpha3 =\u003e 'CAN',\n  #         :continent =\u003e 'North America',\n  #         :region =\u003e 'North America',\n  #         :postal_code =\u003e /^([A-Z]\\d[A-Z][\\-\\s]?\\d[A-Z](\\d)?)$/i\n  #       },\n  #       { :name =\u003e 'United States',\n  #         :numeric =\u003e '840',\n  #         :alpha2 =\u003e 'US',\n  #         :alpha3 =\u003e 'USA',\n  #         :continent =\u003e 'North America',\n  #         :region =\u003e 'North America',\n  #         :postal_code =\u003e /^\\d{5}([\\-\\s]?\\d{4})?$/\n  #       }\n  #    ]\n\n  VST::Validations::Addresses.eu\n  # =\u003e same type of info for the 27 European Union countries\n\u003c/code\u003e\u003c/pre\u003e\n\n### find\\_by\\_* \u0026amp; find\\_all\\_by\\_*\n\nThe VST::Validations::Addresses module also provides *find\\_by\\_\\** (for a single country) and *find\\_all\\_by\\_\\** (for a list of countries)\n\n\u003ccode\u003e\u003cpre\u003e\n  VST::Validations::Addresses.north_america\n  # -- is the same as --\n  VST::Validations::Addresses.find_all_by_continent('North America')\n  \n  VST::Validations::Addresses.find_by_iso_code('840')\n  # =\u003e { :name =\u003e 'United States',\n  #      :numeric =\u003e '840',\n  #      :alpha2 =\u003e 'US',\n  #      :alpha3 =\u003e 'USA',\n  #      :continent =\u003e 'North America',\n  #      :region =\u003e 'North America',\n  #      :postal_code =\u003e /^\\d{5}([\\-\\s]?\\d{4})?$/\n  #    }\n\u003c/pre\u003e\u003c/code\u003e\n\n## Caveats\n\nCurrenty supports the US, Canada and countries from the EU.\nAlso, **this is very much beta and things may change**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeburrows%2Fvalidates_as_postal_code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeburrows%2Fvalidates_as_postal_code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeburrows%2Fvalidates_as_postal_code/lists"}