specify v0.10.0 Specify.Schema View Source

Functions that can be used inside Specify.defconfig/2.

Link to this section Summary

Functions

Specifies a field that is part of the configuration struct.

Link to this section Functions

Link to this macro

field(name, parser \\ :string, options \\ [])

View Source (macro)

Specifies a field that is part of the configuration struct.

Can/should only be called inside a call to Specify.defconfig.

  • name should be an atom representing the field. It will also become the field name for the struct that is created.
  • parser should either be:

    • an arity-one function capture like &YourModule.some_type_parser/1.
    • An atom representing one of the common parser function names in Specify.Parsers like :integer, :string, :boolean or :term.
    • A two-element tuple like {:list, :atom}. The first element represents the 'collection parser' which is an arity-2 function that takes the 'element parser' as second argument. The second element is the 'element parser'. Both of the elements listed in the tuple can also be either an atom, or a function capture with the correct arity. (like {&YourAwesomeModule.fancy_collection/2, :integer}).

parser defaults to :string.

Supported field options are:

  • default:, supplies a default value to this field. If not set, the configuration field is set to be required.

You are highly encouraged to add a @documentation text above each and every field; these will be added to the configuration's module documentation.