Maru.Params.Schema (maru_params v0.2.15)

Copy Markdown

A module holding named params blocks which other modules reuse with include.

defmodule MyApp.Params.Address do
  use Maru.Params.Schema

  params :basic do
    requires :city, String
    requires :zipcode, String
  end

  params :full do
    requires :address_line_1, String
    requires :city, String
    requires :zipcode, String
  end
end

params do ... end defines the anonymous block, named :default.

Options

  • :reads - field names the given conditions of this schema read from the level it is included into, defaults to []
  • :struct and :derive - define a struct from the declared params, same options as Maru.Params.TypeBuilder

Generated functions

__maru_params__()          # block names in declaration order
__maru_params__(:basic)    # params runtime of one block
__maru_reads__()           # the `reads:` option
__maru_given__(:basic)     # literal key/value pairs of the block's givens
__maru_includes__(:basic)  # includes recorded in the block, checked by
                           # Maru.Params.verify_all/1

Summary

Functions

Resolve the params runtime an include refers to, called at runtime by the code include generated.

Functions

params(list)

(macro)

params(name, list)

(macro)

resolve(module, opts \\ [])

Resolve the params runtime an include refers to, called at runtime by the code include generated.