shahryarjb
Cannot invoke remote function Regex.match?/2 inside guard
Hello, I wanted to create custom guard like this , but I have an error:
cannot invoke remote function Regex.match?/2 inside guard
guard:
defmodule TrangellHtmlSite.Blog.GuardCustom do
defmacro amount_cheaker(number) do
quote do
Regex.match?(~r/^([+-]?[1-9]\d*|0)$/, unquote(number))
end
end
end
---
defmodule TrangellHtmlSiteWeb.PayController do
use TrangellHtmlSiteWeb, :controller
alias TrangellHtmlSite.Blog.ZarinPal
import TrangellHtmlSite.Blog.GuardCustom, only: [amount_cheaker: 1]
def check_pay(conn, %{"amount" => amount}) when amount_cheaker(amount) do
conn = put_session(conn, :amount, amount)
%{"{http://zarinpal.com/}Authority" => authority, "{http://zarinpal.com/}Status" => status} = ZarinPal.zarinpal_send(amount)
check_status_send(conn, status, authority)
end
end
How do I fix this?
Most Liked
radarjones
You might want to read this.
4
NobbZ
You can’t. This is a limitation of the BEAM.
2
Popular in Questions
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<...
New
Is there a way to rollback a specific migration and only that one ("skipping" all the other ones)?
Would
mix ecto.rollback -v 2008090...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Other popular topics
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I fore...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar.
I p...
New
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition)
It’s been a while since we first asked this, I...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!)
This post collects co...
New
I would like to know what is the best IDE for elixir development?
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New







