Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Rule reference

Richard Jonas edited this page May 23, 2016 · 5 revisions

The generic rule is described as type specs.

-type field_type() :: atom | binary | string | number | boolean | const |
                      skip | list | record | map | generic | virtual.

-type field_name() :: atom() | string().

-type field_opt()  :: {default, term()} |
                      {pre_encode, fun((term(), term()) -> term())} |
                      {post_decode, fun((term(), term()) -> term())} |
                      base64 |            %% only for binaries
                      recursive |         %% only for generic fields
                      {module, atom()} |  %% only for record fields 
                      {type, atom()}.     %% only for list and record fields

-type field_opts() :: [field_opt()].

-type field_rule() :: {field_type(), field_name(), field_opts()}.

-json({record_name, field_rule(), field_rule(), ...}).
Clone this wiki locally