Skip to content

Commit

Permalink
Add phone_number validations to PressSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-l-brockwell committed Nov 11, 2024
1 parent eb3363e commit a33e7d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/press_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ class PressSummary < ApplicationRecord

validates :form_answer, :token, presence: true
validates :body, presence: true, unless: :contact_details_update?
validates :name, :email, :phone_number,
validates :name, :email,
presence: true,
unless: proc { |c| c.body_update.present? },
if: :applicant_submitted?

validates :phone_number,
phone: true,
unless: proc { |c| c.body_update.present? },
if: :applicant_submitted?

validates :title, :last_name,
presence: true,
unless: proc { |c| c.body_update.present? && form_answer.award_year.year >= 2020 },
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ en:
attributes:
phone_number:
invalid: Enter a phone number, like 01635 960 001, 07701 900 982 or +44 808 157 0192
press_summary:
attributes:
phone_number:
invalid: Enter a phone number, like 01635 960 001, 07701 900 982 or +44 808 157 0192
user:
attributes:
phone_number:
Expand Down

0 comments on commit a33e7d7

Please sign in to comment.