2022-05-04 07:33:06 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RegexpListValidator
|
|
|
|
def initialize(opts = {})
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid_value?(value)
|
|
|
|
value
|
|
|
|
.split("|")
|
|
|
|
.all? do |regexp|
|
|
|
|
begin
|
|
|
|
Regexp.new(regexp)
|
|
|
|
rescue RegexpError => e
|
|
|
|
@regexp = regexp
|
|
|
|
@error_message = e.message
|
|
|
|
false
|
2023-01-09 07:10:19 -05:00
|
|
|
end
|
2022-05-04 07:33:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_message
|
|
|
|
I18n.t(
|
|
|
|
"site_settings.errors.invalid_regex_with_message",
|
|
|
|
regex: @regexp,
|
|
|
|
message: @error_message,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|