Sorcery.Schema.FieldType behaviour (sorcery v0.4.4)

WIP currently it is not possible to add your own custom field types. But in the future it should be possible since they all follow this behaviour

Summary

Callbacks

During validation of a field, we go through every attribute, comparing it to the given value to see if everything is valid.

Callbacks

Link to this callback

get_sd_field(struct)

@callback get_sd_field(struct()) :: %StreamData{generator: term()}
Link to this callback

is_valid?(attr_k, attr_v, value)

@callback is_valid?(attr_k :: atom(), attr_v :: any(), value :: any()) :: boolean()

During validation of a field, we go through every attribute, comparing it to the given value to see if everything is valid.

We do it this way to try to keep everything related to attributes all in one place - the field struct. For example, if you look in Sorcery.Schema.FieldType.Integer, you will find a defstruct that lists several attributes. But there is also the is_valid? function, with a different head for each one.

@callback new(map()) :: struct()

Functions

Link to this function

add_optional(args, meta)

Link to this function

new(args, meta)