xema v0.8.0 Xema.Builder View Source

This module contains some convenience functions to generate schemas.

Examples

iex> import Xema.Builder
...> schema = Xema.new integer(minimum: 1)
...> Xema.valid?(schema, 6)
true
...> Xema.valid?(schema, 0)
false

Link to this section Summary

Functions

Returns a tuple of :any and the given keyword list

Returns a tuple of :atom and the given keyword list

Returns a tuple of :boolean and the given keyword list

Returns a tuple of :float and the given keyword list

Returns a tuple of :integer and the given keyword list

Returns a tuple of :keyword and the given keyword list

Returns a tuple of :list and the given keyword list

Returns a tuple of :map and the given keyword list

Returns a tuple of :number and the given keyword list

Returns the tuple {:ref, ref}

Returns a tuple of :string and the given keyword list

Returns :struct

Returns the tuple {:struct, module: module}

Returns a tuple of :tuple and the given keyword list

Create a function with the name that returns the given schema

Link to this section Functions

Returns a tuple of :any and the given keyword list.

Examples

iex> Xema.Builder.any(key: 42)
{:any, [key: 42]}
Link to this function

any(keywords) View Source
any(keyword()) :: {:any, keyword()}

Returns a tuple of :atom and the given keyword list.

Examples

iex> Xema.Builder.atom(key: 42)
{:atom, [key: 42]}
Link to this function

atom(keywords) View Source
atom(keyword()) :: {:atom, keyword()}

Link to this function

boolean() View Source
boolean() :: :boolean

Returns a tuple of :boolean and the given keyword list.

Examples

iex> Xema.Builder.boolean(key: 42)
{:boolean, [key: 42]}
Link to this function

boolean(keywords) View Source
boolean(keyword()) :: {:boolean, keyword()}

Link to this function

float() View Source
float() :: :float

Returns a tuple of :float and the given keyword list.

Examples

iex> Xema.Builder.float(key: 42)
{:float, [key: 42]}
Link to this function

float(keywords) View Source
float(keyword()) :: {:float, keyword()}

Link to this function

integer() View Source
integer() :: :integer

Returns a tuple of :integer and the given keyword list.

Examples

iex> Xema.Builder.integer(key: 42)
{:integer, [key: 42]}
Link to this function

integer(keywords) View Source
integer(keyword()) :: {:integer, keyword()}

Link to this function

keyword() View Source
keyword() :: :keyword

Returns a tuple of :keyword and the given keyword list.

Examples

iex> Xema.Builder.keyword(key: 42)
{:keyword, [key: 42]}
Link to this function

keyword(keywords) View Source
keyword(keyword()) :: {:keyword, keyword()}

Returns a tuple of :list and the given keyword list.

Examples

iex> Xema.Builder.list(key: 42)
{:list, [key: 42]}
Link to this function

list(keywords) View Source
list(keyword()) :: {:list, keyword()}

Returns a tuple of :map and the given keyword list.

Examples

iex> Xema.Builder.map(key: 42)
{:map, [key: 42]}
Link to this function

map(keywords) View Source
map(keyword()) :: {:map, keyword()}

Link to this function

number() View Source
number() :: :number

Returns a tuple of :number and the given keyword list.

Examples

iex> Xema.Builder.number(key: 42)
{:number, [key: 42]}
Link to this function

number(keywords) View Source
number(keyword()) :: {:number, keyword()}

Returns the tuple {:ref, ref}.

Link to this function

string() View Source
string() :: :string

Returns a tuple of :string and the given keyword list.

Examples

iex> Xema.Builder.string(key: 42)
{:string, [key: 42]}
Link to this function

string(keywords) View Source
string(keyword()) :: {:string, keyword()}

Link to this function

strux() View Source
strux() :: :struct

Returns :struct.

Link to this function

strux(keywords) View Source
strux(keyword()) :: {:struct, keyword()}
strux(atom()) :: {:struct, [{:module, module()}]}

Returns the tuple {:struct, module: module}.

Link to this function

tuple() View Source
tuple() :: :tuple

Returns a tuple of :tuple and the given keyword list.

Examples

iex> Xema.Builder.tuple(key: 42)
{:tuple, [key: 42]}
Link to this function

tuple(keywords) View Source
tuple(keyword()) :: {:tuple, keyword()}

Link to this macro

xema(name, schema) View Source (macro)

Create a function with the name that returns the given schema.