View Source Flint.Extensions.Typed (Flint v0.6.0)

Adds supports for most of the features from the wonderful typed_ecto_schema library.

Rather than using the typed_embedded_schema macro from that library, however, thr Typed extension incorporates the features into the standard embedded_schema macro from Flint.Schema, meaning even fewer lines of code changed to use typed embedded schemas!

Included with that are the addtional Schema-Level options you can pass to the embedded_schema macro.

You also have the ability to override field typespecs as well as providing extra field-level options from typed_ecto_schema.

Required vs Enforced vs Null

Note that the typespecs allow you to specify :enforce and :null options, which are different from the requirement imposed by field!.


field! marks the field as being required during the changeset validation, which is equal to passing the field name to the Eco.Changeset.validate_required/3. An instance of the schema's struct CAN still be created if a field marked with field! is not present.


enforce: true is equal to including that field in the @enforce_keys module attribute for the corresponding schema struct.

An instance of the schema's struct CANNOT be created if a field marked with enforce: true is not present, as it will raise an ArgumentError.


:null indicates whether nil is a valid value for the field. This only impacts the generated typespecs.

Summary

Functions

Link to this macro

embedded_schema(opts \\ [], list)

View Source (macro)