From e520c1f73cee4921fea5dd0e8c4266779e6a5302 Mon Sep 17 00:00:00 2001 From: phil-l-brockwell Date: Tue, 5 Nov 2024 17:15:47 +0000 Subject: [PATCH] Add phone_number validations to PressSummary --- app/models/press_summary.rb | 7 ++++++- config/locales/en.yml | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/press_summary.rb b/app/models/press_summary.rb index dc969eb29..da41e61ff 100644 --- a/app/models/press_summary.rb +++ b/app/models/press_summary.rb @@ -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 }, diff --git a/config/locales/en.yml b/config/locales/en.yml index b6c30030f..edf92aa3c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: