IDUtils.Schemes.VIAF (id_utils v0.1.0)

Copy Markdown View Source

VIAF (Virtual International Authority File) scheme.

See https://www.wikidata.org/wiki/Property:P214

Summary

Functions

Builds a URI for the given VIAF ID.

Checks whether a string is a VIAF ID.

Normalizes a VIAF ID.

Checks whether a string starts with a VIAF prefix.

Functions

build_uri(id)

Builds a URI for the given VIAF ID.

Examples

iex> IDUtils.Schemes.VIAF.build_uri("238999862")
{:ok, %URI{scheme: "https", host: "viaf.org", path: "/viaf/238999862", port: 443}}

match?(string)

Checks whether a string is a VIAF ID.

Examples

iex> IDUtils.Schemes.VIAF.match?("http://viaf.org/viaf/9972147907520779210008")
true

iex> IDUtils.Schemes.VIAF.match?("24609378")
true

iex> IDUtils.Schemes.VIAF.match?("not-a-viaf-id")
false

normalize(string)

Normalizes a VIAF ID.

Examples

iex> IDUtils.Schemes.VIAF.normalize("http://viaf.org/viaf/2736702")
{:ok, "2736702"}

iex> IDUtils.Schemes.VIAF.normalize("VIAF:70596852")
{:ok, "70596852"}

iex> IDUtils.Schemes.VIAF.normalize("not-a-viaf-id")
{:error, :invalid_identifier}

prefix?(string)

@spec prefix?(binary()) :: boolean()

Checks whether a string starts with a VIAF prefix.

Examples

iex> IDUtils.Schemes.VIAF.prefix?("http://viaf.org/viaf/24609378")
true

iex> IDUtils.Schemes.VIAF.prefix?("viaf:24609378")
true

iex> IDUtils.Schemes.VIAF.prefix?("24609378")
false