https://github.com/petoc/vago
Collection of simple validators for Go.
https://github.com/petoc/vago
go golang iso iso-3166-1 iso-3166-2 iso-3166-3 iso-4217 time-zone
Last synced: 5 months ago
JSON representation
Collection of simple validators for Go.
- Host: GitHub
- URL: https://github.com/petoc/vago
- Owner: petoc
- License: mit
- Created: 2020-08-03T16:01:24.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-02T12:57:20.000Z (over 3 years ago)
- Last Synced: 2026-01-15T07:10:23.246Z (5 months ago)
- Topics: go, golang, iso, iso-3166-1, iso-3166-2, iso-3166-3, iso-4217, time-zone
- Language: Go
- Homepage:
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Validators
Collection of simple validators for Go.
## Available validators
[ISO-3166-1](https://github.com/petoc/vago/tree/master/iso31661) (alpha2, alpha3, numeric)
[ISO-3166-2](https://github.com/petoc/vago/tree/master/iso31662)
[ISO-3166-3](https://github.com/petoc/vago/tree/master/iso31663)
[ISO-4217](https://github.com/petoc/vago/tree/master/iso4217)
[Time Zone (IANA)](https://github.com/petoc/vago/tree/master/tz)
## Usage
### ISO-3166-1
```go
import "github.com/petoc/vago/iso31661"
```
```go
iso31661.IsAlpha2("AU") // true
iso31661.NameAlpha2("AU") // Australia
iso31661.IsAlpha3("AUS") // true
iso31661.NameAlpha3("AUS") // Australia
iso31661.IsNumeric("004") // true
iso31661.NameNumeric("AUS") // Australia
iso31661.Is("AU") // true
iso31661.Is("AUS") // true
iso31661.Is("004") // true
iso31661.Name("AU") // Australia
iso31661.Name("AUS") // Australia
iso31661.Name("004") // Australia
```
### ISO-3166-2
```go
import "github.com/petoc/vago/iso31662"
```
```go
iso31662.Is("AU-NSW") // true
iso31662.Name("AU-NSW") // New South Wales, Australia
```
### ISO-3166-3
```go
import "github.com/petoc/vago/iso31663"
```
```go
iso31663.Is("BQAQ") // true
iso31663.Name("BQAQ") // British Antarctic Territory
```
### ISO-4217
```go
import "github.com/petoc/vago/iso4217"
```
```go
iso4217.Is("EUR") // true
iso4217.Name("EUR") // Euro
```
### Time zone (IANA)
```go
import "github.com/petoc/vago/tz"
```
```go
tz.Is("Europe/Berlin") // true
```
## Sources
ISO-3166-1 (https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.json)
ISO-3166-2 (https://github.com/olahol/iso-3166-2.json/blob/master/iso-3166-2.json)
ISO-3166-3 (https://github.com/haliaeetus/iso-3166/blob/master/data/iso_3166-3.json)
ISO-4217 (https://github.com/umpirsky/currency-list/blob/master/data/en/currency.json)
Time Zone (IANA) (https://github.com/eggert/tz/blob/master/zone.tab)
## License
Licensed under MIT license.