Mix.install([
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"},
{:tested_cell, github: "brooklinjazz/tested_cell"},
{:utils, path: "#{__DIR__}/../utils"}
])
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 formatrecipient_name@domain_name.top_level_domain
. i.e."[email protected]"
.age
(optional) an integer.agreed_to_terms_and_conditions
(required) a boolean which must betrue
.
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
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"
Previous | Next |
---|---|
File Types | HTML CSS |