blob: 02ed7dfb4edf02d48f122fe906ea62f10e65070f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
# 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
|