mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-06 10:25:09 +01:00
Fixed linting errors on empty field names validator
This commit is contained in:
parent
4da9244584
commit
0717cdd2ce
@ -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
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user