Packages

Simple, agile, map schema in elixir with type checking, custom types with casting and validation and with json encoding

Current section

Files

Jump to
map_schema lib skeleton macros check.ex
Raw

lib/skeleton/macros/check.ex

defmodule MapSchema.Macros.Check do
@moduledoc false
@doc """
The Check module compone the macros that let us, build the methods is_valid?:
"""
def install do
build_check()
end
defp build_check do
quote do
@doc """
It´s will return true, if the map follow the schema.
"""
def unquote(:is_valid?)(var!(mapa)) when is_map(var!(mapa)) do
put(%{}, var!(mapa))
true
catch
_ -> false
end
def unquote(:is_valid?)(_) do
MapSchema.Exceptions.throw_error_should_be_a_map()
end
end
end
end