blob: 2c715ab4967a0b410f0862fac83cf9a0603da06e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# frozen_string_literal: true
module Types
class UntrustedRegexp < Types::BaseScalar
description 'A regexp containing patterns sourced from user input'
def self.coerce_input(input_value, _)
return unless input_value
Gitlab::UntrustedRegexp.new(input_value)
input_value
rescue RegexpError => e
message = "#{input_value} is an invalid regexp: #{e.message}"
raise GraphQL::CoercionError, message
end
def self.coerce_result(ruby_value, _)
ruby_value.to_s
end
end
end
|