All Projects → vitorsvieira → scala-iso

vitorsvieira / scala-iso

Licence: Apache-2.0 License
ISO 3166-1, ISO 3166-2, ISO 4217, E.164, ISO related types in Scala. Country codes, Country Subdivision, Country Currency, Calling Code, etc...

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to scala-iso

func-dependency-injection-go
Dependency injection example using higher order functions
Stars: ✭ 26 (-23.53%)
Mutual labels:  functional
ustd
Micro-standard-library providing minimal and portable array, queue and map for attiny avr, arduinos, esp8266/32 and linux, mac
Stars: ✭ 14 (-58.82%)
Mutual labels:  functional
vue-if-bot
Hide stuff from bots (especially cookie consents)
Stars: ✭ 62 (+82.35%)
Mutual labels:  functional
TypeInferencer
Algorithm W and Algorithm M in F#
Stars: ✭ 33 (-2.94%)
Mutual labels:  functional
conjson
(conventional, consistent, conformative) JSON - A simple, functional, no-tags-required mechanism to handle and transform JSON representations of values, consistently.
Stars: ✭ 47 (+38.24%)
Mutual labels:  functional
fastener
Functional Zipper for manipulating JSON
Stars: ✭ 54 (+58.82%)
Mutual labels:  functional
iterum
Handling iterables like lazy arrays.
Stars: ✭ 28 (-17.65%)
Mutual labels:  functional
interactive-simple-linear-regression
A PureScript, browser-based implementation of simple linear regression.
Stars: ✭ 15 (-55.88%)
Mutual labels:  functional
ribosome-py
neovim python plugin framework
Stars: ✭ 12 (-64.71%)
Mutual labels:  functional
pyroclastic
Functional dataflow through composable computations
Stars: ✭ 17 (-50%)
Mutual labels:  functional
pygears
HW Design: A Functional Approach
Stars: ✭ 122 (+258.82%)
Mutual labels:  functional
Functional-Light-JS-Zh
《Functional-Light-JS》中文翻译
Stars: ✭ 14 (-58.82%)
Mutual labels:  functional
advxml
A lightweight, simple and functional library DSL to work with XML in Scala with Cats
Stars: ✭ 54 (+58.82%)
Mutual labels:  functional
rudash
Rudash - Lodash for Ruby Apps
Stars: ✭ 27 (-20.59%)
Mutual labels:  functional
react-wisteria
Managing the State with the Golden Path
Stars: ✭ 18 (-47.06%)
Mutual labels:  functional
zio-http4s-example
For anyone who's struggling to put an http4s server together with ZIO
Stars: ✭ 19 (-44.12%)
Mutual labels:  functional
star
An experimental programming language that's made to be powerful, productive, and predictable
Stars: ✭ 88 (+158.82%)
Mutual labels:  functional
njsx
A customizable and declarative interface for creating React and React Native components without JSX syntax.
Stars: ✭ 29 (-14.71%)
Mutual labels:  functional
bitECS
Functional, minimal, data-oriented, ultra-high performance ECS library written in JavaScript
Stars: ✭ 372 (+994.12%)
Mutual labels:  functional
hkts
Functional programming tools: option, either, task, state, optics, etc.
Stars: ✭ 20 (-41.18%)
Mutual labels:  functional

scala-iso

Build Status Software License Maven Central

Motivation

  • One stop shop for ISO related types.

Installation

To get started with SBT, simply add the following to your build.sbt or Build.scala file:

libraryDependencies += "com.vitorsvieira" %% "scala-iso" % "0.1.2"

How to use

The easiest way to use the types available is just adding the following import statement:

import com.vitorsvieira.iso._

ISOCountry

ISOCountry can be retrieved using an alpha-2 code or its numerical code.

scala> ISOCountry("US")
ISOCountry = US
scala> ISOCountry(840)
ISOCountry = US
//or just using the country type
scala> val us = ISOCountry.UNITED_STATES

Using the from method to return an Option[ISOCountry] in case the alpha-2 or numerical code does not exist.

scala> ISOCountry.from("US")
Option[ISOCountry] = Some(US)
scala> ISOCountry.from(840)
Option[ISOCountry] = Some(US)

Also, a list of countries can be returned using the fromContinent method passing a ISOContinent as argument.

scala> val countries = ISOCountry.fromContinent(ISOContinent.ANTARCTICA)
countries: Seq[ISOCountry] = Vector(AQ, BV, TF, HM, GS)

Every ISOCountry is composed by 5 properties:

  • Alpha-2 code, Numerical Code, Formal English Name, Alpha-3 code, ISOContinent
ISOCountry("US", 840, "United States of America", "USA", ISOContinent.NORTH_AMERICA)

ISOCountrySubdivision

val subdivision = ISOCountrySubdivision("US-NY")
subdivision: ISOCountrySubdivision = US-NY
//or
val ny = ISOCountrySubdivision.`New York`
ny: ISOCountrySubdivision = US-NY

Using the from method to return an Option[ISOCountry] in case the alpha-2 or numerical code does not exist.

scala> val optSubdivision = ISOCountrySubdivision.from("US-NY")
optSubdivision: Option[ISOCountrySubdivision] = Some(US-NY)

Also, a list of subdivisions can be returned using the fromCountry method passing a ISOCountry as argument.

scala> val subdivisions = ISOCountrySubdivision.fromCountry(ISOCountry.AUSTRALIA)
subdivisions: Seq[ISOCountrySubdivision] = Vector(AU-ACT, AU-NSW, AU-NT, AU-QLD, AU-SA, AU-TAS, AU-VIC, AU-WA)

Every ISOCountrySubdivision is composed by 3 properties:

  • ISOCountry, Formal English Name, 3166-2 code
ISOCountrySubdivision(ISOCountry.UNITED_STATES, "New York", "US-NY")

ISOCurrency

ISOCurrency can be retrieved using the currency code, numerical code, or ISOCountry.

ISOCurrency("USD")
ISOCurrency(840)
ISOCurrency(ISOCountry.UNITED_STATES)
//or
ISOCurrency.US_DOLLAR

ISOCurrency has the same from method to retrieve a Option[ISOCurrency] as the types above using the same parameters as the method apply.

Every ISOCurrency is composed by 4 properties:

  • Currency code, Numerical Code, Minor Unit, collection of ISOCountry.
ISOCurrency(
  "AUD",
  36,
  2,
  ISOCountry.HEARD_ISLAND_AND_MCDONALD_ISLANDS,
  ISOCountry.TUVALU,
  ISOCountry.KIRIBATI,
  ISOCountry.AUSTRALIA,
  ISOCountry.NORFOLK_ISLAND,
  ISOCountry.NAURU,
  ISOCountry.CHRISTMAS_ISLAND,
  ISOCountry.COCOS_ISLANDS
)

CountryCallingCodes

CountryCallingCode(ISOCountry.UNITED_STATES)
CountryCallingCode("1")
CountryCallingCode(1)
//or just
CountryCallingCode.`+1`

Every CountryCallingCodes is composed by 3 properties:

  • Calling code, Numerical Code, collection of ISOCountry
CountryCallingCode("1", 1, ISOCountry.UNITED_STATES, ISOCountry.CANADA)

Roadmap

  • ISO 3166-1 - codes for the names of countries, dependent territories, and special areas of geographical interest.
  • ISO 3166-2 - codes for identifying the principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1.
  • ISO 4217 - codes for currencies in circulation, composed of a country's two-character Internet country code plus a third character denoting the currency unit.
  • E.164 - country calling codes or country dial in codes are telephone dialing prefixes for the member countries of the International Telecommunication Union.
  • Language / Locales.
  • Banking / Financial.
  • File formats.
  • etc...
  • and other regulated standards direct or indirectly related to ISO.

References

License

This code is open source software licensed under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].