MIT License

项目介绍

FormatterKit/PostalCodeValidator 是一个托管在 GitHub 上的开源项目,主要使用 Swift 编写,采用 MIT License 许可证,目前获得 205 个 Star、14 次 Fork。

仓库全名
FormatterKit/PostalCodeValidator
开源许可证
MIT License
Star 数
205
Fork 数
14

README 摘要

PostalCodeValidator A validator for postal codes with support for 200+ regions. Note: Only the region of a locale is used to determine validation rules. To validate the postal code for a particular region, you can construct a locale using an identifier with the "und" language code. Requirements Swift 4.0+ Installation Swift Package Manager Add the PostalCodeValidator package to your target dependencies in…

完整内容见 GitHub 原始 README 或本页 。

常见问题

PostalCodeValidator 用什么语言开发?

主要使用 Swift 编写,采用 MIT License 许可证,目前有 205 个 Star。

PostalCodeValidator 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 PostalCodeValidator 的源码?

可以直接克隆仓库:git clone https://github.com/FormatterKit/PostalCodeValidator.git,默认分支为 master;安装与运行步骤见仓库 README。

PostalCodeValidator 最近还在维护吗?

仓库最近一次更新为 2020年12月1日,当前没有未关闭的 Issue;Star 数为 205,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

A validator for postal codes with support for 200+ regions

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
233
价值分
127
活跃状态
归档

语言占比

Makefile
Ruby
Swift

贡献者

README

PostalCodeValidator

Build Status License Swift Version

A validator for postal codes with support for 200+ regions.

import Foundation
import PostalCodeValidator

if let validator = PostalCodeValidator(locale: .current) { // United States (US)
    validator.validate(postalCode: "95014") // true
    validator.validate(postalCode: "22162-1010") // true

    validator.validate(postalCode: "1234567") // false
    validator.validate(postalCode: "INVALID") // false
}

// 248 regions supported
if let validator = PostalCodeValidator(regionCode: "JP") { // Japan (JP)
    validator.validate(postalCode: "154-0023") // true
    validator.validate(postalCode: "12345") // false
}

Note: Only the region of a locale is used to determine validation rules. To validate the postal code for a particular region, you can construct a locale using an identifier with the "und" language code.

Requirements

  • Swift 4.0+

Installation

Swift Package Manager

Add the PostalCodeValidator package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(
        url: "https://github.com/FormatterKit/PostalCodeValidator",
        from: "0.1.0"
    ),
  ]
)

Then run the swift build command to build your project.

Known Issues

  • Armed forces in Germany (and likely other countries) use special postal codes, which aren’t included in the upstream data source. This will cause validation of these postal codes to fail. (Thanks for pointing this out, @timohetzel)

Additional Details

The CLDR previously maintained a list of postal code formats, but that information was deprecated in v27.

Following the guidance of the twitter-cldr-rb project, PostalCodeValidator sources its information from http://i18napis.appspot.com. The most recent release of this software uses information retrieved from the website on November 27, 2019.

License

MIT

Contact

Mattt (@mattt)

评论

暂无评论