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() :: yaml_val() | yaml_list() | yaml_map().
-type yaml_list() :: [yaml()].
-type yaml_map() :: [{yaml_val(), yaml()}].
-type yaml_val() :: atom() | number() | binary().

Link to this section Functions

-spec and_then(validator(T1), fun((T1) -> T2)) -> validator(T2).
-spec any() -> validator(yaml()).
-spec atom() -> validator(atom()).
-spec base64() -> validator(binary()).
-spec beam() -> validator(module()).
-spec beam(exports()) -> 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 either(atom(), validator(T)) -> validator(atom() | T);
      (validator(T1), validator(T2)) -> validator(T1 | T2).
-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().
Link to this function

format_error(Unexpected)

View Source
-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)) -> validator([T]).
-spec list(validator(T), [unique_opt() | sorted_opt()]) -> validator([T]).
-spec list_or_single(validator(T)) -> validator([T]).
Link to this function

list_or_single(Fun, Opts)

View Source
-spec list_or_single(validator(T), [unique_opt() | sorted_opt()]) -> validator([T]).
-spec map(validator(T1), validator(T2)) -> validator([{T1, T2}] | #{T1 => T2}).
-spec map(validator(T1), validator(T2), [{return, return_type()} | unique_opt()]) ->
       validator([{T1, T2}] | #{T1 => T2} | dict:dict(T1, T2)).
-spec non_empty(validator(T)) -> validator(T).
-spec non_neg_int() -> validator(non_neg_integer()).
-spec non_neg_int(infinity()) -> validator(non_neg_integer() | infinity()).
-spec number(number()) -> validator(number()).
-spec number(number(), number() | infinity) -> validator(number()).
-spec octal() -> validator(non_neg_integer()).
-spec options(validators()) -> validator().
Link to this function

options(Validators, Options)

View Source
-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_int(infinity()) -> validator(pos_integer() | infinity()).
-spec pos_number() -> validator(number()).
-spec re() -> validator().
-spec re([proplists:property()]) -> validator().
-spec rfc3339_time(time_unit()) -> validator(non_neg_integer()).
-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().