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
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
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
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
I've read in another post that it may be possible with a router helper - but I couldn't find an appropriate one, and tbh, I'm still just ...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Other popular topics
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
Lets say i have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => "XX...
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New







