2020-09-10 21:07:01 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class GroupPinnedStatusValidator < ActiveModel::Validator
|
|
|
|
def validate(groupPin)
|
|
|
|
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.reblog')) if groupPin.status.reblog?
|
2020-11-25 21:22:37 +00:00
|
|
|
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.ungrouped')) unless groupPin.status.group_id
|
|
|
|
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.notGroupStatus')) if groupPin.status.group_id != groupPin.group.id
|
2020-09-10 21:07:01 +01:00
|
|
|
groupPin.errors.add(:base, I18n.t('statuses.group_pin_errors.limit')) if groupPin.group.group_pinned_statuses.count >= 4
|
|
|
|
end
|
|
|
|
end
|