Module: EditsValidations

Extended by:
ActiveSupport::Concern
Included in:
PostHistory, SuggestedEdit
Defined in:
app/models/concerns/edits_validations.rb

Overview

Common validations for unilateral & suggested edits

Instance Method Summary collapse

Instance Method Details

#max_edit_comment_lengthObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/concerns/edits_validations.rb', line 9

def max_edit_comment_length
  if comment.nil?
    return
  end

  max_edit_comment_length = SiteSetting['MaxEditCommentLength']
  max_length = [(max_edit_comment_length || 255), 255].min
  if comment.length > max_length
    msg = I18n.t('edits.max_edit_comment_length', { count: max_length }).gsub(':length', max_length.to_s)
    errors.add(:base, msg)
  end
end