Shun.Verifier (Shun v1.0.1) View Source

Allows verification of an URI, IPv4 address, or IPv6 address using a Provider.

Link to this section Summary

Types

Allows customisation of how verification is handled.

Represents the Provider module, which implements the Shun.Provider behaviour.

Represents the result of URI / IPv4 / IPv6 verification.

Represents the value to be validated, which is either an URI struct, a String, or an IP address represented as a 4-arity or 8-arity tuple.

Functions

Performs verification of the value using the Provider module provided.

Link to this section Types

Specs

option() :: {:resolver, module()} | {:resolver_timeout, timeout()}

Allows customisation of how verification is handled.

At this time the only change allowed is related to resolution of hostnames in URIs. The default resolver is Shun.Resolver.InetRes which wraps :inet_res.lookup/4, but any other module that implements the behaviour Shun.Resolver can be used.

Specs

provider() :: module()

Represents the Provider module, which implements the Shun.Provider behaviour.

Specs

result() :: {:ok, Shun.uri() | [Shun.address(), ...]} | {:error, term()}

Represents the result of URI / IPv4 / IPv6 verification.

In most cases, a pattern-match against {:ok, _} is adequate. In case of URIs that have had their host names resolved for further verification, the underlying IPs will be returned in a list.

Specs

value() :: Shun.name() | Shun.address() | Shun.uri()

Represents the value to be validated, which is either an URI struct, a String, or an IP address represented as a 4-arity or 8-arity tuple.

Link to this section Functions

Link to this function

perform(provider, value, options \\ [])

View Source

Specs

perform(provider(), value(), [option()]) :: result()

Performs verification of the value using the Provider module provided.

In case of Strings being used, it will first be parsed as an URI and validated as URI.