@@ -4,7 +4,6 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
44 use Absinthe.Phase
55 alias Absinthe.Blueprint
66
7- @ valid_name_regex ~r/ ^[_A-Za-z][_0-9A-Za-z]*$/
87
98 def run ( bp , _ ) do
109 bp = Blueprint . prewalk ( bp , & validate_names / 1 )
@@ -30,7 +29,7 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
3029 end
3130
3231 defp valid_name? ( name ) do
33- Regex . match? ( @ valid_name_regex , name )
32+ Regex . match? ( valid_name_regex ( ) , name )
3433 end
3534
3635 defp error ( object , data ) do
@@ -42,23 +41,20 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
4241 }
4342 end
4443
45- @ description """
46- Name does not match possible #{ inspect ( @ valid_name_regex ) } regex.
47-
48- > Names in GraphQL are limited to this ASCII subset of possible characters to
49- > support interoperation with as many other systems as possible.
50-
51- Reference: https://graphql.github.io/graphql-spec/June2018/#sec-Names
52-
53- """
44+ defp valid_name_regex ( ) , do: ~r/ ^[_A-Za-z][_0-9A-Za-z]*$/
5445
5546 def explanation ( % { artifact: artifact , value: value } ) do
5647 artifact_name = String . capitalize ( artifact )
5748
5849 """
5950 #{ artifact_name } #{ inspect ( value ) } has invalid characters.
6051
61- #{ @ description }
52+ Name does not match possible #{ valid_name_regex ( ) } regex.
53+
54+ > Names in GraphQL are limited to this ASCII subset of possible characters to
55+ > support interoperation with as many other systems as possible.
56+
57+ Reference: https://graphql.github.io/graphql-spec/June2018/#sec-Names
6258 """
6359 end
6460end
0 commit comments