Skip to content
/ vago Public

Collection of simple validators for Go.

License

Notifications You must be signed in to change notification settings

petoc/vago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Validators

Collection of simple validators for Go.

Available validators

ISO-3166-1 (alpha2, alpha3, numeric)
ISO-3166-2
ISO-3166-3
ISO-4217
Time Zone (IANA)

Usage

ISO-3166-1

import "github.com/petoc/vago/iso31661"
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

import "github.com/petoc/vago/iso31662"
iso31662.Is("AU-NSW")   // true
iso31662.Name("AU-NSW") // New South Wales, Australia

ISO-3166-3

import "github.com/petoc/vago/iso31663"
iso31663.Is("BQAQ")   // true
iso31663.Name("BQAQ") // British Antarctic Territory

ISO-4217

import "github.com/petoc/vago/iso4217"
iso4217.Is("EUR")   // true
iso4217.Name("EUR") // Euro

Time zone (IANA)

import "github.com/petoc/vago/tz"
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.