Skip to content

Latest commit

 

History

History
72 lines (53 loc) · 2.01 KB

sign_up_form.livemd

File metadata and controls

72 lines (53 loc) · 2.01 KB

Sign Up Form

Mix.install([
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"},
  {:tested_cell, github: "brooklinjazz/tested_cell"},
  {:utils, path: "#{__DIR__}/../utils"}
])

Navigation

Return Home Report An Issue

Sign Up Form

It's common for applications to have a sign up form that validates a user's email, password, and other information.

Create a User module which validates user's information.

{:ok, user} =
  User.new(%{
    username: "Peter Parker",
    password: "secret_spider",
    email: "[email protected]",
    terms_and_conditions: true
  })

We're going to allow any string for the recipient name, domain name, and top level domain.

  • username (required) a 3-12 character string.
  • password (required) a 12-50 character string.
  • email (required) a string in the format recipient_name@domain_name.top_level_domain. i.e. "[email protected]".
  • age (optional) an integer.
  • agreed_to_terms_and_conditions (required) a boolean which must be true.

You should rely on Ecto Changesets and your own custom validation to validate the user information. Enter your solution below.

defmodule User do
  use Ecto.Schema
  import Ecto.Changeset

  def changeset(%User{} = user, params) do
  end

  def new(params) do
  end
end

Commit Your Progress

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

$ git add .
$ git commit -m "finish sign up form exercise"

Up Next

Previous Next
File Types HTML CSS