@@ -4,7 +4,6 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
4
4
use Absinthe.Phase
5
5
alias Absinthe.Blueprint
6
6
7
- @ valid_name_regex ~r/ ^[_A-Za-z][_0-9A-Za-z]*$/
8
7
9
8
def run ( bp , _ ) do
10
9
bp = Blueprint . prewalk ( bp , & validate_names / 1 )
@@ -30,7 +29,7 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
30
29
end
31
30
32
31
defp valid_name? ( name ) do
33
- Regex . match? ( @ valid_name_regex , name )
32
+ Regex . match? ( valid_name_regex ( ) , name )
34
33
end
35
34
36
35
defp error ( object , data ) do
@@ -42,23 +41,20 @@ defmodule Absinthe.Phase.Schema.Validation.NamesMustBeValid do
42
41
}
43
42
end
44
43
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]*$/
54
45
55
46
def explanation ( % { artifact: artifact , value: value } ) do
56
47
artifact_name = String . capitalize ( artifact )
57
48
58
49
"""
59
50
#{ artifact_name } #{ inspect ( value ) } has invalid characters.
60
51
61
- #{ @ description }
52
+ Name does not match possible #{ inspect ( 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
62
58
"""
63
59
end
64
60
end
0 commit comments