The description of one attribute of a Kotoba.Node.
Kotoba.Node.field/3 makes one Kotoba.Node.Field for each attribute.
Kotoba.Node.fields/0 returns them in the order of declaration.
Struct keys
:name- the struct key of the node, an atom.:key- the JSON key.:type-:string,:integer,:boolean,:mapor{:array, type}.:required,:default,:inand:omit_nil- the values of the options below.
Options of field/3
:key- the JSON key. The default is the name as a string.:required- whentrue, the value must not benil. The default isfalse.:default- the struct default.from_json/1also uses it when the JSON has no value for the key. The default isnil.:in- when set, a list of the permitted values.:omit_nil- whentrue,to_json/1does not write the key if the value isnil. Whenfalse(the default),to_json/1writesnull.
Summary
Functions
Checks one value against the field. Returns :ok or {:error, message}.
Builds a field. Raises ArgumentError when the name, the type or an
option is not valid.
Types
Functions
Checks one value against the field. Returns :ok or {:error, message}.
Builds a field. Raises ArgumentError when the name, the type or an
option is not valid.