From 0717cdd2ce8af6ffbfabb0ee02b9e05eb0096b97 Mon Sep 17 00:00:00 2001 From: Tim Rogers Date: Wed, 1 Jan 2025 10:19:09 -0600 Subject: [PATCH] Fixed linting errors on empty field names validator --- .../empty_profile_field_names_validator.rb | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/validators/empty_profile_field_names_validator.rb b/app/validators/empty_profile_field_names_validator.rb index 8b841844d8..0eff54e2d4 100644 --- a/app/validators/empty_profile_field_names_validator.rb +++ b/app/validators/empty_profile_field_names_validator.rb @@ -1,17 +1,15 @@ # frozen_string_literal: true class EmptyProfileFieldNamesValidator < ActiveModel::Validator - def validate(account) - return if account.fields.empty? - field_names_valid = true - account.fields.each_with_index do |field, index| - if field.name.blank? && !field.value.blank? - field_names_valid = false - end - end - return if field_names_valid + def validate(account) + return if account.fields.empty? - account.errors.add(:fields, 'Names of profile fields cannot be empty') + field_names_valid = true + account.fields.each do |field| + field_names_valid = false if field.name.blank? && field.value.present? end + return if field_names_valid + + account.errors.add(:fields, 'Names of profile fields cannot be empty') end - \ No newline at end of file +end \ No newline at end of file