https://github.com/guanting112/taiwan-id-validator
快速驗證台灣身分證、居留證、統一編號 / twid is a lightweight and zero-dependency Go package for validating Taiwan National IDs, Alien Resident Certificates (ARC), and Unified Business Numbers (UBN)
https://github.com/guanting112/taiwan-id-validator
Last synced: 5 months ago
JSON representation
快速驗證台灣身分證、居留證、統一編號 / twid is a lightweight and zero-dependency Go package for validating Taiwan National IDs, Alien Resident Certificates (ARC), and Unified Business Numbers (UBN)
- Host: GitHub
- URL: https://github.com/guanting112/taiwan-id-validator
- Owner: guanting112
- License: mit
- Created: 2025-12-09T16:46:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-12-09T19:04:27.000Z (6 months ago)
- Last Synced: 2025-12-13T11:51:16.429Z (6 months ago)
- Language: Go
- Homepage: https://pkg.go.dev/github.com/guanting112/taiwan-id-validator
- Size: 28.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Taiwan ID Validator (twid)
[](https://github.com/guanting112/taiwan-id-validator/actions/workflows/go.yml)
[](https://pkg.go.dev/github.com/guanting112/taiwan-id-validator)
[](https://opensource.org/licenses/MIT)
`twid` is a lightweight and zero-dependency Go package for validating Taiwan National IDs, Alien Resident Certificates (ARC), and Unified Business Numbers (UBN).
It supports:
- **Taiwan National ID** (中華民國身分證字號)
- **New Alien Resident Certificate** (新式外來人口統一證號) (Since 2021)
- **Old Alien Resident Certificate** (舊式外來人口統一證號)
- **Unified Business Number (UBN)**: Validates company tax IDs, fully supporting the latest logic (including the 7th-digit rule). (新舊格式的統一編號)
## Installation
```bash
go get github.com/guanting112/taiwan-id-validator
```
## Usage
```go
package main
import (
"fmt"
twid "github.com/guanting112/taiwan-id-validator"
)
func main() {
// National ID
fmt.Println(twid.Validate("A123456789")) // true
fmt.Println(twid.ValidateNationId("A123456789")) // true
fmt.Println(twid.ValidateNationId("A123456700")) // false
// Taiwan Company UBN
fmt.Println(twid.ValidateUbn("84149961")) // true
fmt.Println(twid.ValidateUbn("22099131")) // true
fmt.Println(twid.ValidateUbn("!@)(#&6y01)")) // false
fmt.Println(twid.ValidateUbn("25317520")) // false
fmt.Println(twid.ValidateUbn("00000000")) // false
// New ARC
fmt.Println(twid.Validate("A800000014")) // true
fmt.Println(twid.ValidateArcId("A800000014")) // true
fmt.Println(twid.ValidateArcId("A800000015")) // false
// Old ARC
fmt.Println(twid.Validate("AC01234567")) // true
fmt.Println(twid.ValidateArcId("AC01234567")) // true
// Invalid
fmt.Println(twid.Validate("A123456788")) // false
}
```