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, digits_only/1, letters_only/1, remove_whitespace/1, normalize_line_endings/1, strip_non_ascii/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(FZN)) -> pedantic@codec:codec(list(FZN)).
list(Element_codec) ->
pedantic@codec:list(Element_codec).
-file("src/pedantic.gleam", 90).
-spec optional(pedantic@codec:codec(FZR)) -> pedantic@codec:codec(gleam@option:option(FZR)).
optional(Inner_codec) ->
pedantic@codec:optional(Inner_codec).
-file("src/pedantic.gleam", 94).
-spec dict(pedantic@codec:codec(FZV)) -> pedantic@codec:codec(gleam@dict:dict(binary(), FZV)).
dict(Value_codec) ->
pedantic@codec:dict(Value_codec).
-file("src/pedantic.gleam", 99).
-spec object(binary(), GAA) -> pedantic@codec:object_builder(GAA, any()).
object(Name, Constructor) ->
pedantic@codec:object(Name, Constructor).
-file("src/pedantic.gleam", 103).
-spec field(
pedantic@codec:object_builder(fun((GAC) -> GAD), GAE),
binary(),
pedantic@codec:codec(GAC),
fun((GAE) -> GAC)
) -> pedantic@codec:object_builder(GAD, GAE).
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(GAJ)) -> GAL), GAM),
binary(),
pedantic@codec:codec(GAJ),
fun((GAM) -> gleam@option:option(GAJ))
) -> pedantic@codec:object_builder(GAL, GAM).
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((GAS) -> GAT), GAU),
binary(),
pedantic@codec:codec(GAS),
GAS,
fun((GAU) -> GAS)
) -> pedantic@codec:object_builder(GAT, GAU).
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(GAZ, GAZ)) -> pedantic@codec:codec(GAZ).
build(Builder) ->
pedantic@codec:build(Builder).
-file("src/pedantic.gleam", 139).
-spec default(pedantic@codec:codec(gleam@option:option(GBD)), GBD) -> pedantic@codec:codec(GBD).
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(GBH), pedantic@encode:encoder(GBH)) -> pedantic@codec:codec(GBH).
custom(Decoder, Encoder) ->
pedantic@codec:custom(Decoder, Encoder).
-file("src/pedantic.gleam", 153).
-spec refine(
pedantic@codec:codec(GBL),
fun((GBL) -> {ok, GBL} | {error, pedantic@report:error_kind()})
) -> pedantic@codec:codec(GBL).
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 digits_only(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
digits_only(Codec) ->
pedantic@codec:digits_only(Codec).
-file("src/pedantic.gleam", 237).
-spec letters_only(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
letters_only(Codec) ->
pedantic@codec:letters_only(Codec).
-file("src/pedantic.gleam", 241).
-spec remove_whitespace(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
remove_whitespace(Codec) ->
pedantic@codec:remove_whitespace(Codec).
-file("src/pedantic.gleam", 245).
-spec normalize_line_endings(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
normalize_line_endings(Codec) ->
pedantic@codec:normalize_line_endings(Codec).
-file("src/pedantic.gleam", 249).
-spec strip_non_ascii(pedantic@codec:codec(binary())) -> pedantic@codec:codec(binary()).
strip_non_ascii(Codec) ->
pedantic@codec:strip_non_ascii(Codec).
-file("src/pedantic.gleam", 253).
-spec positive(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
positive(Codec) ->
pedantic@codec:positive(Codec).
-file("src/pedantic.gleam", 257).
-spec negative(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
negative(Codec) ->
pedantic@codec:negative(Codec).
-file("src/pedantic.gleam", 261).
-spec non_negative(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
non_negative(Codec) ->
pedantic@codec:non_negative(Codec).
-file("src/pedantic.gleam", 265).
-spec non_positive(pedantic@codec:codec(integer())) -> pedantic@codec:codec(integer()).
non_positive(Codec) ->
pedantic@codec:non_positive(Codec).
-file("src/pedantic.gleam", 269).
-spec length(pedantic@codec:codec(binary()), integer()) -> pedantic@codec:codec(binary()).
length(Codec, Len) ->
pedantic@codec:length(Codec, Len).
-file("src/pedantic.gleam", 273).
-spec email(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
email(Codec, Msg) ->
pedantic@codec:email(Codec, Msg).
-file("src/pedantic.gleam", 277).
-spec uuid(pedantic@codec:codec(binary()), binary()) -> pedantic@codec:codec(binary()).
uuid(Codec, Msg) ->
pedantic@codec:uuid(Codec, Msg).
-file("src/pedantic.gleam", 281).
-spec check(pedantic@codec:codec(GDV), fun((GDV) -> boolean()), binary()) -> pedantic@codec:codec(GDV).
check(Codec, Predicate, Msg) ->
pedantic@codec:check(Codec, Predicate, Msg).
-file("src/pedantic.gleam", 289).
-spec assert_that(
pedantic@codec:codec(GDY),
fun((GDY) -> boolean()),
pedantic@report:error_kind()
) -> pedantic@codec:codec(GDY).
assert_that(Codec, Predicate, Error) ->
pedantic@codec:assert_that(Codec, Predicate, Error).
-file("src/pedantic.gleam", 297).
-spec with_error_formatter(
pedantic@codec:codec(GEB),
fun((gleam@dynamic:dynamic_(), pedantic@report:error_kind()) -> binary())
) -> pedantic@codec:codec(GEB).
with_error_formatter(Codec, Formatter) ->
pedantic@codec:with_error_formatter(Codec, Formatter).
-file("src/pedantic.gleam", 304).
-spec with_error_message(pedantic@codec:codec(GEE), binary()) -> pedantic@codec:codec(GEE).
with_error_message(Codec, Msg) ->
pedantic@codec:with_error_message(Codec, Msg).
-file("src/pedantic.gleam", 308).
-spec with_template(pedantic@codec:codec(GEH), binary()) -> pedantic@codec:codec(GEH).
with_template(Codec, Template) ->
pedantic@codec:with_template(Codec, Template).
-file("src/pedantic.gleam", 312).
-spec min_size(pedantic@codec:codec(list(GEK)), integer()) -> pedantic@codec:codec(list(GEK)).
min_size(Codec, Minimum) ->
pedantic@codec:min_size(Codec, Minimum).
-file("src/pedantic.gleam", 316).
-spec max_size(pedantic@codec:codec(list(GEP)), integer()) -> pedantic@codec:codec(list(GEP)).
max_size(Codec, Maximum) ->
pedantic@codec:max_size(Codec, Maximum).
-file("src/pedantic.gleam", 320).
-spec non_empty_list(pedantic@codec:codec(GEU)) -> pedantic@codec:codec(list(GEU)).
non_empty_list(Element_codec) ->
pedantic@codec:non_empty_list(Element_codec).
-file("src/pedantic.gleam", 325).
-spec title(pedantic@codec:codec(GEY), binary()) -> pedantic@codec:codec(GEY).
title(Codec, Name) ->
pedantic@codec:title(Codec, Name).
-file("src/pedantic.gleam", 329).
-spec describe(pedantic@codec:codec(GFB), binary()) -> pedantic@codec:codec(GFB).
describe(Codec, Desc) ->
pedantic@codec:describe(Codec, Desc).
-file("src/pedantic.gleam", 333).
-spec example(pedantic@codec:codec(GFE), gleam@dynamic:dynamic_()) -> pedantic@codec:codec(GFE).
example(Codec, Ex) ->
pedantic@codec:example(Codec, Ex).
-file("src/pedantic.gleam", 338).
-spec decode_json(pedantic@codec:codec(GFH), binary()) -> {ok, GFH} |
{error, pedantic@report:report()}.
decode_json(Codec, Json_string) ->
pedantic@json:decode_json(Codec, Json_string).
-file("src/pedantic.gleam", 342).
-spec encode_json(pedantic@codec:codec(GFL), GFL) -> binary().
encode_json(Codec, Val) ->
pedantic@json:encode_json(Codec, Val).
-file("src/pedantic.gleam", 347).
-spec safe_parse(pedantic@codec:codec(GFN), gleam@dynamic:dynamic_()) -> {ok,
GFN} |
{error, pedantic@report:report()}.
safe_parse(Codec, Val) ->
(erlang:element(3, erlang:element(3, Codec)))(Val).
-file("src/pedantic.gleam", 351).
-spec safe_parse_json(pedantic@codec:codec(GFR), binary()) -> {ok, GFR} |
{error, pedantic@report:report()}.
safe_parse_json(Codec, Json_string) ->
pedantic@json:decode_json(Codec, Json_string).
-file("src/pedantic.gleam", 358).
-spec any_of(list(pedantic@decode:decoder(GFV))) -> pedantic@decode:decoder(GFV).
any_of(Decoders) ->
pedantic@decode:any_of(Decoders).
-file("src/pedantic.gleam", 362).
-spec map(pedantic@decode:decoder(GFZ), fun((GFZ) -> GGB)) -> pedantic@decode:decoder(GGB).
map(Decoder, Transform_fn) ->
pedantic@decode:map(Decoder, Transform_fn).