Current section
Files
Jump to
Current section
Files
src/gauth@user@creation@middleware.erl
-module(gauth@user@creation@middleware).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([logging/1, trim_name/1, within_length/2]).
-file("src\\gauth\\user\\creation\\middleware.gleam", 19).
-spec logging(binary()) -> {ok, binary()} |
{error, gauth@user@creation:user_creation_error()}.
logging(Name) ->
gleam_stdlib:println(<<"Creating user with name: "/utf8, Name/binary>>),
{ok, Name}.
-file("src\\gauth\\user\\creation\\middleware.gleam", 24).
-spec trim_name(binary()) -> {ok, binary()} |
{error, gauth@user@creation:user_creation_error()}.
trim_name(Name) ->
{ok,
begin
_pipe = Name,
gleam@string:trim(_pipe)
end}.
-file("src\\gauth\\user\\creation\\middleware.gleam", 28).
-spec within_length(integer(), integer()) -> fun((binary()) -> {ok, binary()} |
{error, gauth@user@creation:user_creation_error()}).
within_length(Min, Max) ->
fun(Name) -> case string:length(Name) of
Len when Len < Min ->
{error,
{invalid_name,
Name,
<<"Name is too short, must be atleast "/utf8,
(erlang:integer_to_binary(Min))/binary>>}};
Len@1 when Len@1 > Max ->
{error,
{invalid_name,
Name,
<<"Name is too long, must be atmost "/utf8,
(erlang:integer_to_binary(Max))/binary>>}};
_ ->
{ok, Name}
end end.