Xema.Builder.field

You're seeing just the function field, go back to Xema.Builder module for more information.
Link to this function

field(name, type, opts \\ [])

View Source

Specs

field(atom(), Xema.Schema.type() | module(), keyword()) ::
  {:xema, Xema.t()} | {:module, module()} | {:type, atom()}

Specifies a field. This function will be used inside xema/0.

Arguments:

  • name: the name of the field.
  • type: the type of the field. The type can also be a struct or another schema.
  • opts: the rules for the field.

Examples

iex> defmodule User do
...>   use Xema
...>
...>   xema do
...>     field :name, :string, min_length: 1
...>   end
...> end
...>
iex> %{"name" => "Tim"} |> User.cast!() |> Map.from_struct()
%{name: "Tim"}

For more examples see "Examples: Struct".