From 0b39cc1b6da27a9f0bb9eaf1b2a216ea95a571cb Mon Sep 17 00:00:00 2001 From: Leonid Brujev Date: Thu, 28 Sep 2023 10:33:44 +0100 Subject: [PATCH] refactoring identifier validation rules --- app/models/pafs_core/area.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/pafs_core/area.rb b/app/models/pafs_core/area.rb index 055e4fe8..0556f619 100644 --- a/app/models/pafs_core/area.rb +++ b/app/models/pafs_core/area.rb @@ -14,8 +14,8 @@ class Area < ApplicationRecord validates :name, :area_type, presence: true validates :name, uniqueness: true - validates :identifier, presence: true, if: :rma? || :authority?, unless: :skip_identifier_validation - validates :identifier, uniqueness: true, if: :rma? || :authority?, unless: :skip_identifier_validation + validates :identifier, presence: true, if: -> { rma? || authority? }, unless: :skip_identifier_validation + validates :identifier, uniqueness: true, if: -> { rma? || authority? }, unless: :skip_identifier_validation validate :parentage validates :area_type, inclusion: { in: AREA_TYPES } validates :sub_type, presence: true, if: :rma?