mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-29 08:29:03 +01:00
5255bd08e0
# Conflicts: # app/views/admin/settings/shared/_links.html.haml # config/routes/admin.rb
13 lines
340 B
Ruby
13 lines
340 B
Ruby
# frozen_string_literal: true
|
|
|
|
class RegexpSyntaxValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
return if value.blank?
|
|
|
|
begin
|
|
Regexp.compile(value)
|
|
rescue RegexpError => e
|
|
record.errors.add(attribute, I18n.t('applications.invalid_regexp', message: e.message))
|
|
end
|
|
end
|
|
end
|