Skip to content

Commit

Permalink
Use custom validation on example app
Browse files Browse the repository at this point in the history
  • Loading branch information
trenpixster committed May 3, 2016
1 parent d731001 commit 17134fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example_app/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ config :phoenix, :generators,

config :addict,
secret_key: "2432622431322479506177654c79303442354a5a4b784f592e444f332e",
extra_validation: fn ({valid, errors}, user_params) -> {valid, errors} end, # define extra validation here
extra_validation: &ExampleApp.User.validate/2, # define extra validation here
user_schema: ExampleApp.User,
repo: ExampleApp.Repo,
from_email: "[email protected]", # CHANGE THIS
Expand Down
4 changes: 4 additions & 0 deletions example_app/web/models/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ defmodule ExampleApp.User do
model
|> cast(params, @required_fields, @optional_fields)
end

def validate({valid, errors}, user_params) do
{valid, errors}
end
end

0 comments on commit 17134fd

Please sign in to comment.