diff --git a/app/models/merge_people.rb b/app/models/merge_people.rb index 9ea3c51a15..f23733f1c7 100644 --- a/app/models/merge_people.rb +++ b/app/models/merge_people.rb @@ -65,6 +65,15 @@ def person2_must_not_have_associated_user end end + validate :person2_year_must_not_be_earlier + def person2_year_must_not_be_earlier + year1 = person1_wca_id[0, 4].to_i + year2 = person2_wca_id[0, 4].to_i + if year2 < year1 + errors.add(:person2_wca_id, "WCA ID year cannot be earlier than person1's WCA ID year") + end + end + def do_merge if !valid? return false