View Source CastParams.Schema (CastParams v0.0.5)
Defines a params schema for a plug.
A params schema is just a keyword list where keys are the parameter name
and the value is either a valid CastParams.Type
(ending with a !
to mark the parameter as required).
Example
CastParams.Schema.init(age: :integer, terms: :boolean!, name: :string, weight: :float)
Summary
Functions
Init schema
Types
@type t() :: [{name :: atom(), CastParams.Type.t()}]
Functions
@spec init(options :: list()) :: [CastParams.Param.t()]
Init schema
Examples
iex> init(age: :integer)
[%CastParams.Param{names: ["age"], type: :integer}]
iex> init([age: :integer!])
[%CastParams.Param{names: ["age"], type: :integer, required: true}]
iex> init([terms: :boolean!, name: :string, age: :integer])
[
%CastParams.Param{names: ["terms"], type: :boolean, required: true},
%CastParams.Param{names: ["name"], required: false, type: :string},
%CastParams.Param{names: ["age"], required: false, type: :integer},
]