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

Link to this function

any(keywords \\ []) View Source
any(keyword()) :: {:any, keyword()}

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

Examples

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

atom(keywords \\ []) View Source
atom(keyword()) :: {:atom, 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

boolean(keywords \\ []) View Source
boolean(keyword()) :: {:boolean, keyword()}

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

Examples

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

defxema(name, schema) View Source (macro)

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

Link to this function

float(keywords \\ []) View Source
float(keyword()) :: {:float, keyword()}

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

Examples

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

integer(keywords \\ []) View Source
integer(keyword()) :: {:integer, keyword()}

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

Examples

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

keyword(keywords \\ []) 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]}
Link to this function

list(keywords \\ []) View Source
list(keyword()) :: {:list, 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

map(keywords \\ []) View Source
map(keyword()) :: {:map, 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

number(keywords \\ []) View Source
number(keyword()) :: {:number, keyword()}

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

Examples

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

Returns the tuple {:ref, ref}.

Link to this function

string(keywords \\ []) View Source
string(keyword()) :: {:string, keyword()}

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

Examples

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

struct(keywords \\ []) View Source
struct(keyword()) :: {:struct, keyword()}

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

Examples

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

tuple(keywords \\ []) View Source
tuple(keyword()) :: {:tuple, keyword()}

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

Examples

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