Skip to content

Commit

Permalink
Configured email validation on update
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbruce committed May 7, 2015
1 parent 5982b05 commit 64e59cd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User < ActiveRecord::Base
validates :role, :name, presence: true
validates :email, format: {
with: email_regex,
on: :create,
on: [:create, :update],
allow_nil: true,
message: I18n.t('dictionary.invalid_email', email: Settings.mail_tech_support)
}
Expand Down
9 changes: 2 additions & 7 deletions app/views/users/edit.html.slim
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
h2 Edit #{@user.email}
h2 Edit #{@user.name}

= form_for @user do |f|
- if @user.errors.any?
#error_explanation
h2 = "#{pluralize(@user.errors.count, "error")} prohibited this user from being saved:"
ul
- @user.errors.full_messages.each do |message|
li = message

.form-group
= f.label :email, @user.errors[:email].join(', ').html_safe, class: 'error' if @user.errors[:email].present?
= f.label :email
= f.text_field :email
.form-group
Expand Down
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ en:
attributes:
email:
blank: 'Enter your email address'
invalid: You must enter an @hmcts.gsi.gov.uk email address
not_found: That email is not registered on our system
name:
blank: You must enter a name for the user
Expand Down

0 comments on commit 64e59cd

Please sign in to comment.