mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-16 15:57:22 +00:00
13 lines
309 B
Ruby
13 lines
309 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UntrustedRegexpValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
return unless value
|
|
|
|
Gitlab::UntrustedRegexp.new(value)
|
|
|
|
rescue RegexpError => e
|
|
record.errors.add(attribute, "not valid RE2 syntax: #{e.message}")
|
|
end
|
|
end
|