View Source ndto (ndto v0.3.1)
ndto
's main module.
Summary
Functions
Generates an Erlang Syntax Tree of a DTO module from a schema
Equivalent to load(DTO, []).
Loads a DTO module into the Erlang Runtime System
Writes a DTO module to a file
Types
-type array() :: [value()].
-type array_schema() :: #{type := array, items => schema() | [schema()], additional_items => schema(), min_items => non_neg_integer(), max_items => non_neg_integer(), unique_items => boolean(), optional => boolean(), nullable => boolean()}.
-type empty_schema() :: false.
-type format() :: iso8601 | base64.
-type name() :: atom().
-type null() :: null.
-type object_schema() :: #{type := object, properties => #{binary() => schema()}, required => [binary()], min_properties => non_neg_integer(), max_properties => non_neg_integer(), pattern_properties => #{pattern() => schema()}, additional_properties => schema(), optional => boolean(), nullable => boolean()}.
-type pattern() :: binary().
-type schema() :: empty_schema() | universal_schema() | ref_schema() | enum_schema() | boolean_schema() | integer_schema() | float_schema() | string_schema() | array_schema() | object_schema() | union_schema() | intersection_schema() | complement_schema() | symmetric_difference_schema().
-type string_schema() :: #{type := string, min_length => non_neg_integer(), max_length => non_neg_integer(), format => format(), pattern => pattern(), optional => boolean(), nullable => boolean()}.
-type t() :: erl_syntax:syntaxTree().
-type universal_schema() :: true | #{} | union_schema().
Functions
-spec load(DTO) -> Result when DTO :: t(), Result :: ok | {ok, Warnings} | error | {error, {Errors, Warnings}}, Errors :: [term()], Warnings :: [term()].
Equivalent to load(DTO, []).
-spec load(DTO, Options) -> Result when DTO :: t(), Options :: [compile:option()], Result :: ok | {ok, Warnings} | error | {error, {Errors, Warnings}}, Errors :: [term()], Warnings :: [term()].
-spec write(DTO, Filename) -> Result when DTO :: t(), Filename :: file:filename(), Result :: ok | {error, Reason}, Reason :: invalid | file:posix() | badarg | terminated | system_limit.