Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Email Validation

email_validation.livemd

Email Validation

Mix.install([
  {:kino, github: "livebook-dev/kino", override: true},
  {:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
  {:vega_lite, "~> 0.1.4"},
  {:kino_vega_lite, "~> 0.1.1"},
  {:benchee, "~> 0.1"},
  {:ecto, "~> 3.7"},
  {:math, "~> 0.7.0"},
  {:faker, "~> 0.17.0"},
  {:utils, path: "#{__DIR__}/../utils"},
  {:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])

Navigation

Return Home Report An Issue

Email Validation

Most applications and websites with users have a sign up form with an email input.

Generally, we validate this input to ensure that users enter a valid email.

You are going to build an Email.validate/1 function which checks if an email address is valid or not.

Email.validate("mail@mail.com")
true

Emails are generally in the format:

"recipientname@domainname.topleveldomain"

For the sake of simplicity, we’re going to allow any string for the recipient name, domain name, and top level domain.

So, "string@string.string"

Here’s a few examples.

true = Email.validate("peter.parker@spider.web")
true = Email.validate("bruce@wayne.tech")
true = Email.validate("123@456.789")

# This would normally not be a valid email, but will pass our simple validation
true = Email.validate("!#$@*&().&&&")

Enter your solution below

defmodule Email do
  def validate(email) do
  end
end

Utils.feedback(:email_validation, Email)

This simple validation works for many use cases, however there are more comprehensive rules for email validation.

Generally applications send users a verification email to further ensure that the email address exists and belongs to them.

Commit Your Progress

Run the following in your command line from the project folder to track and save your progress in a Git commit.

$ git add .
$ git commit -m "finish email validation exercise"