View Source Want.Shape (want v1.17.1)
Provides macros for declaring an Ecto-like schema definition that can be used
to cast incoming data. Most of the macro logic here was adapted from Ecto.Schema
.
Summary
Functions
Cast incoming data based on a Shape definition.
Cast incoming data based on a Shape definition. Raises on error.
Cast a list of maps to a list of Shapes.
Cast a list of maps to a list of Shapes.
Define a field within a shape.
Determine whether the given module represents a shape.
Define a shape schema. Generates a struct definition for the current module that includes the data needed to correctly cast incoming JSON/map data into that struct, including field sourcing, type conversions, etc.
Define a shape schema. Generates a struct definition for the current module that includes the data needed to correctly cast incoming JSON/map data into that struct, including field sourcing, type conversions, etc.
Functions
Cast incoming data based on a Shape definition.
Cast incoming data based on a Shape definition. Raises on error.
Cast a list of maps to a list of Shapes.
Cast a list of maps to a list of Shapes.
Define a field within a shape.
Determine whether the given module represents a shape.
Define a shape schema. Generates a struct definition for the current module that includes the data needed to correctly cast incoming JSON/map data into that struct, including field sourcing, type conversions, etc.
Define a shape schema. Generates a struct definition for the current module that includes the data needed to correctly cast incoming JSON/map data into that struct, including field sourcing, type conversions, etc.
Options
:transform
- A function that accepts the generated shape struct and performs any transformations required. Called after a successful cast.