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
NobbZ
Popular in Questions
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
In templates/appointment/index.html.eex:
<%= for appointment <- @appointments do %>
<tr>
<td><%= appoi...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









