35 karma · joined Dec 13, 2013 (12y ago) · 4 submissions
comment 1y ago · link · parent
This particular issue is with a binary (i.e. pre-built) package, normally in Arch it's expected from an AUR package that you will build it yourself and most if not all packagers prompt you to review and or edit the PKGBUILD before it does anything.
Basically you could spot something suspicious in a source package, not so much in a binary package.
comment 2y ago · link · parent
I just hope that "h :ets" works in iex later (for those who don't know, it shows the help/module/function documentation of the value specified)
comment 2y ago · link · parent
For the email validation I would have used an ecto schema, since most cases you won't just be validating an email address in isolation:
defmodule EmailSchema do
use Ecto.Schema
import Ecto.Changeset
@primary_key false
embedded_schema do
# here is your type validation right off the bat
field :email, :string
end
def validate(email) do
%__MODULE__{}
|> cast(params, [
:email,
])
|> validate_required([
:email,
])
|> validate_change(:email, fn :email, value ->
cond do
not is_email_address?(value) ->
[email: {"invalid email address", [validation: :email]}]
not EmailAddresses.is_available?(value) ->
[email: {"is unavailable", [validation: :email]}]
true ->
[]
end
end)
|> apply_action(:insert)
end
end
case EmailSchema.validate(email) do
{:ok, %{email: email}} ->
{:error, %Ecto.Changeset{} = changeset} ->
changeset.errors[:email]
# Can be all of these in the same list, or be any one depending on the validations
#=> [{"is required", [validation: :required]}]
#=> [{"invalid email address", [validation: :email]}]
#=> [{"is unavailable", [validation: :email]}]
endcomment 4y ago · link · parent
For personal projects? Ruby and Elixir, though ruby's documentation has fallen off of shape as of late, that or Elixir's has spoiled me by setting higher bar
I see you mentioned RoR, you can try Phoenix in its place for Elixir.