View Source yval (yval v1.0.10)
Link to this section Summary
Link to this section Types
-type ctx() :: [atom() | binary() | integer()].
-type error_reason() :: term().
-type error_return() :: {error, error_reason(), ctx()}.
-type exports() :: [{atom(), arity()} | [{atom(), arity()}]].
-type infinity() :: infinity | infinite | unlimited.
-type options() :: [{atom(), term()}] | #{atom() => term()} | dict:dict(atom(), term()).
-type return_type() :: list | map | dict | orddict.
-type sorted_opt() :: sorted | {sorted, boolean()}.
-type time_unit() :: microsecond | millisecond | nanosecond | second.
-type timeout_unit() :: millisecond | second | minute | hour | day.
-type unique_opt() :: unique | {unique, boolean()}.
-type validator() :: fun((yaml()) -> term()).
-type validator(T) :: fun((yaml()) -> T).
-type validator_option() :: {required, [atom()]} | {defaults, #{atom() => term()}} | {disallowed, [atom()]} | unique | {unique, boolean()} | {return, return_type()}.
-type validators() :: #{atom() => validator()}.
-type yaml_list() :: [yaml()].
-type yaml_val() :: atom() | number() | binary().
Link to this section Functions
-spec atom() -> validator(atom()).
-spec base64() -> validator(binary()).
-spec beam() -> validator(module()).
-spec binary() -> validator(binary()).
-spec binary(iodata()) -> validator(binary()).
-spec binary(iodata(), [proplists:property()]) -> validator(binary()).
-spec binary_sep(iodata()) -> validator([binary()]).
-spec bool() -> validator(boolean()).
-spec directory() -> validator(binary()).
-spec directory(read | write) -> validator(binary()).
-spec enum([atom() | binary()]) -> validator(atom() | binary()).
-spec fail(module(), term()) -> no_return().
-spec file() -> validator(binary()).
-spec file(read | write) -> validator(binary()).
-spec format_ctx(ctx()) -> string().
-spec format_error(error_reason()) -> string().
-spec format_error(error_reason(), ctx()) -> string().
-spec glob() -> validator().
-spec glob([proplists:property()]) -> validator().
-spec hex() -> validator(binary()).
-spec int() -> validator(integer()).
-spec int(integer(), integer() | infinity) -> validator(integer()).
-spec ip() -> validator(inet:ip_address()).
-spec ip_mask() -> validator({inet:ip4_address(), 0..32} | {inet:ip6_address(), 0..128}).
-spec ipv4() -> validator(inet:ip4_address()).
-spec ipv6() -> validator(inet:ip6_address()).
-spec list(validator(T), [unique_opt() | sorted_opt()]) -> validator([T]).
-spec list_or_single(validator(T), [unique_opt() | sorted_opt()]) -> validator([T]).
-spec map(validator(T1), validator(T2), [{return, return_type()} | unique_opt()]) -> validator([{T1, T2}] | #{T1 => T2} | dict:dict(T1, T2)).
-spec non_neg_int() -> validator(non_neg_integer()).
-spec number(number()) -> validator(number()).
-spec number(number(), number() | infinity) -> validator(number()).
-spec octal() -> validator(non_neg_integer()).
-spec options(validators()) -> validator().
-spec options(validators(), [validator_option()]) -> validator().
-spec path() -> validator(binary()).
-spec percent() -> validator(number()).
-spec percent(number(), number() | infinity) -> validator(number()).
-spec port() -> validator(1..65535).
-spec pos_int() -> validator(pos_integer()).
-spec pos_number() -> validator(number()).
-spec re() -> validator().
-spec re([proplists:property()]) -> validator().
-spec string() -> validator(string()).
-spec string(iodata()) -> validator(string()).
-spec string(iodata(), [proplists:property()]) -> validator(string()).
-spec term() -> validator(term()).
-spec timeout(timeout_unit()) -> validator(pos_integer()).
-spec timeout(timeout_unit(), infinity()) -> validator(pos_integer() | infinity()).
-spec url() -> validator(binary()).
-spec url([atom()]) -> validator(binary()).
-spec validate(validator(), yaml()) -> {ok, any()} | error_return().