xema v0.9.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.
Creates a schema
.
Creates a schema
with the given name.
Link to this section Functions
any()
View Source
any() :: :any
any() :: :any
Returns a tuple of :any
and the given keyword list.
Examples
iex> Xema.Builder.any(key: 42)
{:any, [key: 42]}
any(keywords) View Source
atom()
View Source
atom() :: :atom
atom() :: :atom
Returns a tuple of :atom
and the given keyword list.
Examples
iex> Xema.Builder.atom(key: 42)
{:atom, [key: 42]}
atom(keywords) View Source
boolean()
View Source
boolean() :: :boolean
boolean() :: :boolean
Returns a tuple of :boolean
and the given keyword list.
Examples
iex> Xema.Builder.boolean(key: 42)
{:boolean, [key: 42]}
boolean(keywords) View Source
float()
View Source
float() :: :float
float() :: :float
Returns a tuple of :float
and the given keyword list.
Examples
iex> Xema.Builder.float(key: 42)
{:float, [key: 42]}
float(keywords) View Source
integer()
View Source
integer() :: :integer
integer() :: :integer
Returns a tuple of :integer
and the given keyword list.
Examples
iex> Xema.Builder.integer(key: 42)
{:integer, [key: 42]}
integer(keywords) View Source
keyword()
View Source
keyword() :: :keyword
keyword() :: :keyword
Returns a tuple of :keyword
and the given keyword list.
Examples
iex> Xema.Builder.keyword(key: 42)
{:keyword, [key: 42]}
keyword(keywords) View Source
list()
View Source
list() :: :list
list() :: :list
Returns a tuple of :list
and the given keyword list.
Examples
iex> Xema.Builder.list(key: 42)
{:list, [key: 42]}
list(keywords) View Source
map()
View Source
map() :: :map
map() :: :map
Returns a tuple of :map
and the given keyword list.
Examples
iex> Xema.Builder.map(key: 42)
{:map, [key: 42]}
map(keywords) View Source
number()
View Source
number() :: :number
number() :: :number
Returns a tuple of :number
and the given keyword list.
Examples
iex> Xema.Builder.number(key: 42)
{:number, [key: 42]}
number(keywords) View Source
ref(ref) View Source
Returns the tuple {:ref, ref}
.
string()
View Source
string() :: :string
string() :: :string
Returns a tuple of :string
and the given keyword list.
Examples
iex> Xema.Builder.string(key: 42)
{:string, [key: 42]}
string(keywords) View Source
strux()
View Source
strux() :: :struct
strux() :: :struct
Returns :struct
.
strux(keywords) View Source
Returns the tuple {:struct, module: module}
.
strux(module, keywords) View Source
tuple()
View Source
tuple() :: :tuple
tuple() :: :tuple
Returns a tuple of :tuple
and the given keyword list.
Examples
iex> Xema.Builder.tuple(key: 42)
{:tuple, [key: 42]}
tuple(keywords) View Source
xema(list) View Source (macro)
Creates a schema
.
xema(name, list) View Source (macro)
Creates a schema
with the given name.