]>
cat aescling's git repositories - mastodon.git/blob - app/validators/note_length_validator.rb
1 # frozen_string_literal: true
3 class NoteLengthValidator
< ActiveModel
::EachValidator
4 def validate_each(record
, attribute
, value
)
5 record
.errors
.add(attribute
, I18n
.t('statuses.over_character_limit', max
: options
[:maximum])) if too_long
?(value
)
11 countable_text(value
).mb_chars
.grapheme_length
> options
[:maximum]
14 def countable_text(value
)
15 return '' if value
.nil?
17 value
.dup
.tap
do |new_text
|
18 new_text
.gsub!
(FetchLinkCardService
::URL_PATTERN, 'x' * 23)
19 new_text
.gsub!
(Account
::MENTION_RE, '@\2')
This page took 0.091118 seconds and 5 git commands to generate.