evalidate (evalidate v0.1.0)

View Source

Summary

Functions

Types

key/0

-type key() :: term().

option/0

-type option() :: {tag_key, char()}.

options/0

-type options() :: [option()].

schema/0

-type schema() :: #{key() => validator()}.

subject/0

-type subject() :: #{key() => term()}.

validator/0

-type validator() :: [validator_fun()] | validator_fun().

validator_fun/0

-type validator_fun() :: fun((Value :: term()) -> validator_return()).

validator_return/0

-type validator_return() ::
          true | false | discard | {true, NewValue :: term()} | {false, Reason :: term()} | no_return().

Functions

binary()

-spec binary() -> validator_fun().

boolean()

-spec boolean() -> validator_fun().

date()

-spec date() -> validator_fun().

date(Opts)

-spec date(Opts :: evalidate_calendar:options()) -> validator_fun().

datetime()

-spec datetime() -> validator_fun().

datetime(Opts)

-spec datetime(Opts :: evalidate_calendar:options()) -> validator_fun().

default(Default)

-spec default(Default :: term()) -> validator_fun().

discard()

-spec discard() -> validator_fun().

discard(Validator)

-spec discard(Validator :: validator()) -> validator_fun().

email()

-spec email() -> validator_fun().

enum(L)

-spec enum(L :: [term()]) -> validator_fun().

eq(N)

-spec eq(N :: integer()) -> validator_fun().

equal(String)

-spec equal(String :: unicode:chardata()) -> validator_fun().

equal(String, IgnoreCase)

-spec equal(String :: unicode:chardata(), IgnoreCase :: boolean()) -> validator_fun().

float()

-spec float() -> validator_fun().

ge(N)

-spec ge(N :: number()) -> validator_fun().

gt(N)

-spec gt(N :: number()) -> validator_fun().

integer()

-spec integer() -> validator_fun().

invalid()

-spec invalid() -> validator_fun().

invalid(Reason)

-spec invalid(Reason :: term()) -> validator_fun().

iolist()

-spec iolist() -> validator_fun().

iolist_max_size(Max)

-spec iolist_max_size(Max :: non_neg_integer()) -> validator_fun().

iolist_min_size(Min)

-spec iolist_min_size(Min :: non_neg_integer()) -> validator_fun().

iolist_size(Min, Max)

-spec iolist_size(Min :: non_neg_integer(), Max :: non_neg_integer()) -> validator_fun().

ip()

-spec ip() -> validator_fun().

ip(Opts)

-spec ip(Opts :: evalidate_net:options()) -> validator_fun().

ipv4()

-spec ipv4() -> validator_fun().

ipv4(Opts)

-spec ipv4(Opts :: evalidate_net:options()) -> validator_fun().

ipv6()

-spec ipv6() -> validator_fun().

ipv6(Opts)

-spec ipv6(Opts :: evalidate_net:options()) -> validator_fun().

json()

-spec json() -> validator_fun().

json(Encoder)

-spec json(Encoder :: json:encoder()) -> validator_fun().

le(N)

-spec le(N :: number()) -> validator_fun().

length(Min, Max)

-spec length(Min :: non_neg_integer(), Max :: non_neg_integer()) -> validator_fun().

list()

-spec list() -> validator_fun().

list(Layout)

-spec list(Layout :: [validator()]) -> validator_fun().

list_length(Min, Max)

-spec list_length(Min :: non_neg_integer(), Max :: non_neg_integer()) -> validator_fun().

list_max_length(Max)

-spec list_max_length(Max :: non_neg_integer()) -> validator_fun().

list_min_length(Min)

-spec list_min_length(Min :: non_neg_integer()) -> validator_fun().

list_of(Validator)

-spec list_of(validator()) -> validator_fun().

lowercase()

-spec lowercase() -> validator_fun().

lt(N)

-spec lt(N :: number()) -> validator_fun().

map()

-spec map() -> validator_fun().

map(Schema)

-spec map(Schema :: schema()) -> validator_fun().

map(Schema, Opts)

-spec map(Schema :: schema(), Opts :: options()) -> validator_fun().

map_max_size(Max)

-spec map_max_size(Max :: non_neg_integer()) -> validator_fun().

map_merge(M)

-spec map_merge(M :: map()) -> validator_fun().

map_min_size(Min)

-spec map_min_size(Min :: non_neg_integer()) -> validator_fun().

map_size(Min, Max)

-spec map_size(Min :: non_neg_integer(), Max :: non_neg_integer()) -> validator_fun().

match(V0)

-spec match(term()) -> validator_fun().

max(Max)

-spec max(Max :: number()) -> validator_fun().

max_length(Max)

-spec max_length(Max :: non_neg_integer()) -> validator_fun().

min(Min)

-spec min(Min :: number()) -> validator_fun().

min_length(Min)

-spec min_length(Min :: non_neg_integer()) -> validator_fun().

ne(N)

-spec ne(N :: integer()) -> validator_fun().

negate(Validator)

-spec negate(Validator :: validator()) -> validator_fun().

non_empty()

-spec non_empty() -> validator_fun().

non_neg_integer()

nullable()

-spec nullable() -> validator_fun().

nullable(Validator)

-spec nullable(Validator :: validator()) -> validator_fun().

number()

-spec number() -> validator_fun().

one_of(ValidatorList)

-spec one_of(ValidatorList :: [validator()]) -> validator_fun().

only(Key, Value, Schema)

-spec only(key(), term(), schema()) -> {ok, term()} | {error, term()}.

only(Key, Value, Schema, Opts)

-spec only(key(), term(), schema(), options()) -> {ok, term()} | {error, term()}.

optional()

-spec optional() -> validator_fun().

optional(Validator)

-spec optional(validator()) -> validator_fun().

pad(Length, Dir, Char)

-spec pad(Length, Dir, Char) -> validator_fun()
             when
                 Length :: integer(),
                 Dir :: leading | trailing | both,
                 Char :: string:grapheme_cluster().

port()

-spec port() -> validator_fun().

prefix(Prefix)

-spec prefix(Prefix :: unicode:chardata()) -> validator_fun().

prefix(Prefix, RemovePrefix)

-spec prefix(Prefix :: unicode:chardata(), RemovePrefix :: boolean()) -> validator_fun().

range(Min, Max)

-spec range(Min :: non_neg_integer() | infinity, Max :: non_neg_integer() | infinity) -> validator_fun().

re(Regex, Opts)

-spec re(Regex, Opts) -> validator_fun()
            when Regex :: re:mp() | iodata() | unicode:charlist(), Opts :: re:options().

required()

-spec required() -> validator_fun().

required(Validator)

-spec required(Validator :: validator()) -> validator_fun().

return()

-spec return() -> validator_fun().

return(Value)

-spec return(Value :: term()) -> validator_fun().

similar(String, Confidence)

-spec similar(String :: unicode:chardata(), Confidence :: float()) -> validator_fun().

sort()

-spec sort() -> validator_fun().

sort(Fn)

-spec sort(Fn) -> validator_fun() when Fn :: fun((T, T) -> boolean()).

suffix(Suffix)

-spec suffix(Suffix :: unicode:chardata()) -> validator_fun().

suffix(Suffix, RemoveSuffix)

-spec suffix(Suffix :: unicode:chardata(), RemoveSuffix :: boolean()) -> validator_fun().

time()

-spec time() -> validator_fun().

time(Opts)

-spec time(Opts :: evalidate_calendar:options()) -> validator_fun().

titlecase()

-spec titlecase() -> validator_fun().

trim()

-spec trim() -> validator_fun().

trim(Dir)

-spec trim(leading | trailing | both) -> validator_fun().

trim(Dir, Char)

-spec trim(leading | trailing | both, Char :: [string:grapheme_cluster()]) -> validator_fun().

tuple()

-spec tuple() -> validator_fun().

tuple(Layout)

-spec tuple(Layout :: tuple()) -> validator_fun().

tuple_max_size(Max)

-spec tuple_max_size(Max :: non_neg_integer()) -> validator_fun().

tuple_min_size(Min)

-spec tuple_min_size(Min :: non_neg_integer()) -> validator_fun().

tuple_size(Min, Max)

-spec tuple_size(Min :: non_neg_integer(), Max :: non_neg_integer()) -> validator_fun().

unicode(Encoding)

-spec unicode(Encoding :: unicode:encoding()) -> validator_fun().

unique()

-spec unique() -> validator_fun().

uppercase()

-spec uppercase() -> validator_fun().

usort()

-spec usort() -> validator_fun().

usort(Fn)

-spec usort(Fn) -> validator_fun() when Fn :: fun((T, T) -> boolean()).

utf8()

-spec utf8() -> validator_fun().

validate(Subject, Schema)

-spec validate(subject(), schema()) -> {ok, subject()} | {error, term()}.

validate(Subject, Schema, Options)

-spec validate(subject(), schema(), options()) -> {ok, subject()} | {error, term()}.

value(Value, R)

-spec value(Value :: term(), validator()) ->
               {true, term()} | {false, Reason :: term()} | discard | no_return().

with(WithKeys, Subject, Schema)

-spec with([key()], subject(), schema()) -> {ok, subject()} | {error, term()}.

with(WithKeys, Subject, Schema, Opts)

-spec with([key()], subject(), schema(), options()) -> {ok, subject()} | {error, term()}.

without(WithoutKeys, Subject, Schema)

-spec without([key()], subject(), schema()) -> {ok, subject()} | {error, term()}.

without(WithoutKeys, Subject, Schema, Opts)

-spec without([key()], subject(), schema(), options()) -> {ok, subject()} | {error, term()}.