Last Updated: February 25, 2016
· hairyhum

Erlang dynamic typecheck with sheriff

Threre are parse-transform for type-checking erlang values in runtime.

Here is an example:

-compile({parse_transform, sheriff}).
-type my_type() :: {integer(), binary()}.

check_some_types(Val) ->
  true = sheriff:check(Val, my_type),
  true = sheriff:check(Val, {external, type}),
  true = sheriff:check(Val, "external:type()"),
  true = sheriff:chack(Val, "{integer(), binary()}").  

Function sheriff:check/2 return true or false on success or error.
It supports internel types (defined in module), external (exported in other module) and inline types (defined in string).

At the moment it does not support types in variables like: sheriff:check(Val, Type) but we are working on it)