From 87745561a1b5061601905b126c92b951eb3b1592 Mon Sep 17 00:00:00 2001 From: JG Date: Mon, 11 Jul 2022 13:17:28 +0100 Subject: [PATCH] validation error messages for scheme --- app/models/scheme.rb | 4 ++++ config/locales/en.yml | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/app/models/scheme.rb b/app/models/scheme.rb index bafa7d395..6fac3daae 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -4,6 +4,10 @@ class Scheme < ApplicationRecord has_many :locations has_many :case_logs + validates_presence_of :service_name + validates_presence_of :scheme_type + validates_presence_of :registered_under_care_act + scope :filter_by_id, ->(id) { where(id: (id.start_with?("S") ? id[1..] : id)) } scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") } scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } diff --git a/config/locales/en.yml b/config/locales/en.yml index 4c3083b10..16f87f198 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -46,6 +46,13 @@ en: owning_organisation_id: required: "Enter the existing organisation’s name" invalid: "Enter the existing organisation’s name" + blank: "Enter the existing organisation’s name" + service_name: + blank: "Enter the scheme’s name" + scheme_type: + blank: "Select the scheme’s type" + registered_under_care_act: + blank: "You must tell us if this scheme is registered under the Care Standards Act 2000" validations: organisation: