View Source edb_dap_parse (edb v0.4.0)

Support for parsing of request arguments, etc

Summary

Types

field_parser()

-type field_parser() :: value_parser() | {optional, value_parser()}.

parser(T)

-type parser(T) :: fun((term()) -> {ok, T}).

template()

-type template() :: #{atom() => field_parser()}.

value_parser()

-type value_parser() :: parser(term()) | template().

Functions

atom()

-spec atom() -> parser(atom()).

atom(A)

-spec atom(A) -> parser(A2) when A :: atom(), A2 :: dynamic().

atoms(As)

-spec atoms([A]) -> parser(A2) when A :: atom(), A2 :: dynamic().

binary()

-spec binary() -> parser(binary()).

boolean()

-spec boolean() -> parser(boolean()).

choice(Options)

-spec choice([parser(T)]) -> parser(T).

empty_list()

-spec empty_list() -> parser([none()]).

list(Parser)

-spec list(parser(T)) -> parser([T]).

map(KParser, VParser)

-spec map(parser(K), parser(V)) -> parser(#{K => V}).

non_neg_integer()

-spec non_neg_integer() -> parser(non_neg_integer()).

nonempty_list(Parser)

-spec nonempty_list(parser(T)) -> parser([T, ...]).

null()

-spec null() -> parser(null).

number()

-spec number() -> parser(number()).

parse/3

-spec parse(template(), term(), allow_unknown | reject_unknown) ->
               {ok, map()} | {error, HumarReadableReason :: binary()}.

template(Template)

-spec template(Template) -> parser(map()) when Template :: template().