-module(migrant@lib). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([get_or_make_migration/3, validate_direction/2]). -spec get_or_make_migration( binary(), gleam@dict:dict(binary(), migrant@types:migration()), fun((migrant@types:migration()) -> {ok, {binary(), migrant@types:migration()}} | {error, migrant@types:error()}) ) -> {ok, {binary(), migrant@types:migration()}} | {error, migrant@types:error()}. get_or_make_migration(Name, Migrations, Next) -> case gleam@dict:get(Migrations, Name) of {ok, Migration} -> Next(Migration); {error, _} -> Next({migration, none, none}) end. -spec validate_direction( binary(), fun((binary()) -> {ok, {binary(), migrant@types:migration()}} | {error, migrant@types:error()}) ) -> {ok, {binary(), migrant@types:migration()}} | {error, migrant@types:error()}. validate_direction(Direction, Next) -> case Direction of <<"up"/utf8>> -> Next(<<"up"/utf8>>); <<"down"/utf8>> -> Next(<<"down"/utf8>>); _ -> {error, {filename_error, <<"Expected `up` or `down`"/utf8>>}} end.