graphql-schema-directive-constraint 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +3 -1
- data/README.md +13 -13
- data/graphql-schema-directive-constraint.gemspec +2 -2
- data/lib/graphql/schema/directive/constraint.rb +14 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9474de7a5dcc0cfd75e6f5950751418a7c3cdf680d98a6e44daf872f7e3f3e33
|
4
|
+
data.tar.gz: 8c1feefb9dcb12a136caa168b1107a7c7bf57712cc87f8ad3e6f08703ca334b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a3a0802cbb6281da84c207c748f410e7a0e9609f70423a0832aab9073298c0d6171b270106f80761928f6433183c93bf91b1755c5c9c37269b5e2ca3e5467c
|
7
|
+
data.tar.gz: 2df0a5065089e369c0dbf10733e1aab1c243012a9d9621efd84caa29375d35f6ab254ff4b184fba6469a655a7da5dcf181258e95de010582d66325d728eb97ed
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Allows using @constraint as a directive to validate input data for [graphql-ruby](https://graphql-ruby.org).
|
4
4
|
|
5
|
-
This gem is
|
5
|
+
This gem is greatly inspired by [confuser/graphql-constraint-directive](https://github.com/confuser/graphql-constraint-directive)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -93,18 +93,18 @@ This example only generates `@constraint` directive on schema but it does not va
|
|
93
93
|
- [x] constraint
|
94
94
|
- [ ] validator
|
95
95
|
- [ ] Integer
|
96
|
-
- [
|
97
|
-
- [
|
98
|
-
- [
|
99
|
-
- [
|
100
|
-
- [
|
101
|
-
- [
|
102
|
-
- [
|
103
|
-
- [
|
104
|
-
- [
|
105
|
-
- [
|
106
|
-
- [
|
107
|
-
- [
|
96
|
+
- [x] min
|
97
|
+
- [x] constraint
|
98
|
+
- [x] validator
|
99
|
+
- [x] max
|
100
|
+
- [x] constraint
|
101
|
+
- [x] validator
|
102
|
+
- [x] exclusiveMin
|
103
|
+
- [x] constraint
|
104
|
+
- [x] validator
|
105
|
+
- [x] exclusiveMax
|
106
|
+
- [x] constraint
|
107
|
+
- [x] validator
|
108
108
|
- [ ] multipleOf
|
109
109
|
- [ ] constraint
|
110
110
|
- [ ] validator
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "graphql-schema-directive-constraint"
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.3.0"
|
6
6
|
spec.authors = ["Ryota Yoshikawa"]
|
7
7
|
spec.email = ["yoshikawa@topotal.com"]
|
8
8
|
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
|
-
spec.add_dependency "graphql", "~>
|
35
|
+
spec.add_dependency "graphql", "~> 2.0"
|
36
36
|
|
37
37
|
spec.add_development_dependency "rake", "~> 13.0"
|
38
38
|
spec.add_development_dependency "rspec", "~> 3.0"
|
@@ -32,6 +32,12 @@ module GraphQL
|
|
32
32
|
argument(:pattern, String, description: "Ensure value matches regex, e.g. alphanumeric", required: false)
|
33
33
|
argument(:format, String, description: "Ensure value is in a particular format", required: false)
|
34
34
|
|
35
|
+
argument(:min, Integer, description: "Ensure value is greater than or equal to", required: false)
|
36
|
+
argument(:max, Integer, description: "Ensure value is less than or equal to", required: false)
|
37
|
+
argument(:exclusiveMin, Integer, description: "Ensure value is greater than", required: false)
|
38
|
+
argument(:exclusiveMax, Integer, description: "Ensure value is less than", required: false)
|
39
|
+
argument(:multipleOf, Integer, description: "Ensure value is a multiple", required: false)
|
40
|
+
|
35
41
|
argument(:without_validator, Boolean, description: "Use constraint directive without validator", required: false)
|
36
42
|
|
37
43
|
locations(
|
@@ -53,6 +59,14 @@ module GraphQL
|
|
53
59
|
owner.validates({ length: { maximum: maxLength } })
|
54
60
|
in [:pattern, pattern]
|
55
61
|
owner.validates({ format: { with: pattern } })
|
62
|
+
in [:min, min]
|
63
|
+
owner.validates({ numericality: { greater_than_or_equal_to: min } })
|
64
|
+
in [:max, max]
|
65
|
+
owner.validates({ numericality: { less_than_or_equal_to: max } })
|
66
|
+
in [:exclusiveMin, exclusiveMin]
|
67
|
+
owner.validates({ numericality: { greater_than: exclusiveMin } })
|
68
|
+
in [:exclusiveMax, exclusiveMax]
|
69
|
+
owner.validates({ numericality: { less_than: exclusiveMax } })
|
56
70
|
else
|
57
71
|
raise NotImplementedError("Given arguments are not implemented yet")
|
58
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-schema-directive-constraint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Yoshikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.2.
|
112
|
+
rubygems_version: 3.2.33
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Allows using @constraint as a directive to validate input data.
|