Current section
Files
Jump to
Current section
Files
src/pedantic.erl
-module(pedantic).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/pedantic.gleam").
-export([list/1, optional/1, dict/1, object/2, field/4, key_optional/4, key_with_default/5, build/1, default/2, custom/2, refine/2, min/2, max/2, min_length/2, max_length/2, trim/1, lowercase/1, uppercase/1, collapse_whitespace/1, replace/3, remove_chars/2, allow_chars/2, strip_control_chars/1, normalize_email/1, normalize_uuid/1, default_if_blank/2, empty_as_none/1, positive/1, negative/1, non_negative/1, non_positive/1, length/2, email/2, uuid/2, check/3, assert_that/3, with_error_formatter/2, with_error_message/2, with_template/2, min_size/2, max_size/2, non_empty_list/1, title/2, describe/2, example/2, decode_json/2, encode_json/2, safe_parse/2, safe_parse_json/2, any_of/1, map/2]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/pedantic.gleam", 86).
-spec list(pedantic@codec:codec(FXA)) -> pedantic@codec:codec(list(FXA)).
list(Element_codec) ->
pedantic@codec:list(Element_codec).
-file("src/pedantic.gleam", 90).
-spec optional(pedantic@codec:codec(FXE)) -> pedantic@codec:codec(gleam@option:option(FXE)).
optional(Inner_codec) ->
pedantic@codec:optional(Inner_codec).
-file("src/pedantic.gleam", 94).
-spec dict(pedantic@codec:codec(FXI)) -> pedantic@codec:codec(gleam@dict:dict(binary(), FXI)).
dict(Value_codec) ->
pedantic@codec:dict(Value_codec).
-file("src/pedantic.gleam", 99).
-spec object(binary(), FXN) -> pedantic@codec:object_builder(FXN, any()).
object(Name, Constructor) ->
pedantic@codec:object(Name, Constructor).
-file("src/pedantic.gleam", 103).
-spec field(
pedantic@codec:object_builder(fun((FXP) -> FXQ), FXR),
binary(),
pedantic@codec:codec(FXP),
fun((FXR) -> FXP)
) -> pedantic@codec:object_builder(FXQ, FXR).
field(Builder, Name, Field_codec, Get) ->
pedantic@codec:field(Builder, Name, Field_codec, Get).
-file("src/pedantic.gleam", 116).
-spec key_optional(
pedantic@codec:object_builder(fun((gleam@option:option(FXW)) -> FXY), FXZ),
binary(),
pedantic@codec:codec(FXW),
fun((FXZ) -> gleam@option:option(FXW))
) -> pedantic@codec:object_builder(FXY, FXZ).
key_optional(Builder, Name, Field_codec, Get) ->
pedantic@codec:key_optional(Builder, Name, Field_codec, Get).
-file("src/pedantic.gleam", 125).
-spec key_with_default(
pedantic@codec:object_builder(fun((FYF) -> FYG), FYH),
binary(),
pedantic@codec:codec(FYF),
FYF,
fun((FYH) -> FYF)
) -> pedantic@codec:object_builder(FYG, FYH).
key_with_default(Builder, Name, Field_codec, Default_val, Get) ->
pedantic@codec:key_with_default(
Builder,
Name,
Field_codec,
Default_val,
Get
).
-file("src/pedantic.gleam", 135).
-spec build(pedantic@codec:object_builder(FYM, FYM)) -> pedantic@codec:codec(FYM).
build(Builder) ->
pedantic@codec:build(Builder).
-file("src/pedantic.gleam", 139).
-spec default(pedantic@codec:codec(gleam@option:option(FYQ)), FYQ) -> pedantic@codec:codec(FYQ).
default(Codec, Default_val) ->
pedantic@codec:default(Codec, Default_val).
-file("src/pedantic.gleam", 148).
?DOC(" Creates a Codec by custom pairing a standalone Decoder and Encoder.\n").
-spec custom(pedantic@decode:decoder(FYU), pedantic@encode:encoder(FYU)) -> pedantic@codec:codec(FYU).
custom(Decoder, Encoder) ->
pedantic@codec:custom(Decoder, Encoder).
-file("src/pedantic.gleam", 153).
-spec refine(
pedantic@codec:codec(FYY),
fun((FYY) -> {ok, FYY} | {error, pedantic@report:error_kind()})
) -> pedantic@codec:codec(FYY).
refine(Codec, Rule) ->
pedantic@codec:refine(Codec, Rule).
-file("src/pedantic.gleam", 160).
-spec min(pedantic@codec:codec(integer()), integer()) -> pedantic@codec:codec(integer()).
min(Codec, Minimum) ->
pedantic@codec:min(Codec, Minimum).
-file("src/pedantic.gleam", 164).
-spec max(pedantic@codec:codec(integer()), integer()) -> pedantic@codec:codec(integer()).
max(Codec, Maximum) ->
pedantic@codec:max(Codec, Maximum).
-file("src/pedantic.gleam", 168).
-spec min_length(pedantic@codec:codec(binary()), integer()) -> pedantic@codec:codec(binary()).
min_length(Codec, Minimum) ->
pedantic@codec:min_length(Codec, Minimum).
-file("src/pedantic.gleam", 172).
-spec max_length(pedantic@codec:codec(binary()), integer()) -> pedantic@codec:codec(binary()).
max_length(Codec, Maximum) ->
pedantic@codec:max_length(Codec, Maximum).
-file("src/pedantic.gleam", 178).
-spec trim(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
trim(Codec) ->
pedantic@codec:trim(Codec).
-file("src/pedantic.gleam", 182).
-spec lowercase(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
lowercase(Codec) ->
pedantic@codec:lowercase(Codec).
-file("src/pedantic.gleam", 186).
-spec uppercase(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
uppercase(Codec) ->
pedantic@codec:uppercase(Codec).
-file("src/pedantic.gleam", 190).
-spec collapse_whitespace(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
collapse_whitespace(Codec) ->
pedantic@codec:collapse_whitespace(Codec).
-file("src/pedantic.gleam", 194).
-spec replace(pedantic@codec:codec(binary()), binary(), binary()) -> pedantic@codec:codec(binary()).
replace(Codec, Pattern, Replacement) ->
pedantic@codec:replace(Codec, Pattern, Replacement).
-file("src/pedantic.gleam", 202).
-spec remove_chars(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
remove_chars(Codec, Characters) ->
pedantic@codec:remove_chars(Codec, Characters).
-file("src/pedantic.gleam", 206).
-spec allow_chars(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
allow_chars(Codec, Characters) ->
pedantic@codec:allow_chars(Codec, Characters).
-file("src/pedantic.gleam", 210).
-spec strip_control_chars(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
strip_control_chars(Codec) ->
pedantic@codec:strip_control_chars(Codec).
-file("src/pedantic.gleam", 214).
-spec normalize_email(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
normalize_email(Codec) ->
pedantic@codec:normalize_email(Codec).
-file("src/pedantic.gleam", 218).
-spec normalize_uuid(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
normalize_uuid(Codec) ->
pedantic@codec:normalize_uuid(Codec).
-file("src/pedantic.gleam", 222).
-spec default_if_blank(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
default_if_blank(Codec, Default_value) ->
pedantic@codec:default_if_blank(Codec, Default_value).
-file("src/pedantic.gleam", 229).
-spec empty_as_none(pedantic@codec:codec(binary())) -> pedantic@codec:codec(gleam@option:option(binary())).
empty_as_none(Codec) ->
pedantic@codec:empty_as_none(Codec).
-file("src/pedantic.gleam", 233).
-spec positive(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
positive(Codec) ->
pedantic@codec:positive(Codec).
-file("src/pedantic.gleam", 237).
-spec negative(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
negative(Codec) ->
pedantic@codec:negative(Codec).
-file("src/pedantic.gleam", 241).
-spec non_negative(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
non_negative(Codec) ->
pedantic@codec:non_negative(Codec).
-file("src/pedantic.gleam", 245).
-spec non_positive(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
non_positive(Codec) ->
pedantic@codec:non_positive(Codec).
-file("src/pedantic.gleam", 249).
-spec length(pedantic@codec:codec(binary()), integer()) -> pedantic@codec:codec(binary()).
length(Codec, Len) ->
pedantic@codec:length(Codec, Len).
-file("src/pedantic.gleam", 253).
-spec email(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
email(Codec, Msg) ->
pedantic@codec:email(Codec, Msg).
-file("src/pedantic.gleam", 257).
-spec uuid(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
uuid(Codec, Msg) ->
pedantic@codec:uuid(Codec, Msg).
-file("src/pedantic.gleam", 261).
-spec check(pedantic@codec:codec(GAY), fun((GAY) -> boolean()), binary()) -> pedantic@codec:codec(GAY).
check(Codec, Predicate, Msg) ->
pedantic@codec:check(Codec, Predicate, Msg).
-file("src/pedantic.gleam", 269).
-spec assert_that(
pedantic@codec:codec(GBB),
fun((GBB) -> boolean()),
pedantic@report:error_kind()
) -> pedantic@codec:codec(GBB).
assert_that(Codec, Predicate, Error) ->
pedantic@codec:assert_that(Codec, Predicate, Error).
-file("src/pedantic.gleam", 277).
-spec with_error_formatter(
pedantic@codec:codec(GBE),
fun((gleam@dynamic:dynamic_(), pedantic@report:error_kind()) -> binary())
) -> pedantic@codec:codec(GBE).
with_error_formatter(Codec, Formatter) ->
pedantic@codec:with_error_formatter(Codec, Formatter).
-file("src/pedantic.gleam", 284).
-spec with_error_message(pedantic@codec:codec(GBH), binary()) -> pedantic@codec:codec(GBH).
with_error_message(Codec, Msg) ->
pedantic@codec:with_error_message(Codec, Msg).
-file("src/pedantic.gleam", 288).
-spec with_template(pedantic@codec:codec(GBK), binary()) -> pedantic@codec:codec(GBK).
with_template(Codec, Template) ->
pedantic@codec:with_template(Codec, Template).
-file("src/pedantic.gleam", 292).
-spec min_size(pedantic@codec:codec(list(GBN)), integer()) -> pedantic@codec:codec(list(GBN)).
min_size(Codec, Minimum) ->
pedantic@codec:min_size(Codec, Minimum).
-file("src/pedantic.gleam", 296).
-spec max_size(pedantic@codec:codec(list(GBS)), integer()) -> pedantic@codec:codec(list(GBS)).
max_size(Codec, Maximum) ->
pedantic@codec:max_size(Codec, Maximum).
-file("src/pedantic.gleam", 300).
-spec non_empty_list(pedantic@codec:codec(GBX)) -> pedantic@codec:codec(list(GBX)).
non_empty_list(Element_codec) ->
pedantic@codec:non_empty_list(Element_codec).
-file("src/pedantic.gleam", 305).
-spec title(pedantic@codec:codec(GCB), binary()) -> pedantic@codec:codec(GCB).
title(Codec, Name) ->
pedantic@codec:title(Codec, Name).
-file("src/pedantic.gleam", 309).
-spec describe(pedantic@codec:codec(GCE), binary()) -> pedantic@codec:codec(GCE).
describe(Codec, Desc) ->
pedantic@codec:describe(Codec, Desc).
-file("src/pedantic.gleam", 313).
-spec example(pedantic@codec:codec(GCH), gleam@dynamic:dynamic_()) -> pedantic@codec:codec(GCH).
example(Codec, Ex) ->
pedantic@codec:example(Codec, Ex).
-file("src/pedantic.gleam", 318).
-spec decode_json(pedantic@codec:codec(GCK), binary()) -> {ok, GCK} |
{error, pedantic@report:report()}.
decode_json(Codec, Json_string) ->
pedantic@json:decode_json(Codec, Json_string).
-file("src/pedantic.gleam", 322).
-spec encode_json(pedantic@codec:codec(GCO), GCO) -> binary().
encode_json(Codec, Val) ->
pedantic@json:encode_json(Codec, Val).
-file("src/pedantic.gleam", 327).
-spec safe_parse(pedantic@codec:codec(GCQ), gleam@dynamic:dynamic_()) -> {ok,
GCQ} |
{error, pedantic@report:report()}.
safe_parse(Codec, Val) ->
(erlang:element(3, erlang:element(3, Codec)))(Val).
-file("src/pedantic.gleam", 331).
-spec safe_parse_json(pedantic@codec:codec(GCU), binary()) -> {ok, GCU} |
{error, pedantic@report:report()}.
safe_parse_json(Codec, Json_string) ->
pedantic@json:decode_json(Codec, Json_string).
-file("src/pedantic.gleam", 338).
-spec any_of(list(pedantic@decode:decoder(GCY))) -> pedantic@decode:decoder(GCY).
any_of(Decoders) ->
pedantic@decode:any_of(Decoders).
-file("src/pedantic.gleam", 342).
-spec map(pedantic@decode:decoder(GDC), fun((GDC) -> GDE)) -> pedantic@decode:decoder(GDE).
map(Decoder, Transform_fn) ->
pedantic@decode:map(Decoder, Transform_fn).