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