graphql-schema-directive-constraint 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c8c07eb7fe477e2bd35091d83a581b66b0b2251dddf6fb419f2bd590951929c
4
- data.tar.gz: 308e7da11091e893d880215b1ba4db18f949a823a34d8faf9179d83582bc9626
3
+ metadata.gz: 9474de7a5dcc0cfd75e6f5950751418a7c3cdf680d98a6e44daf872f7e3f3e33
4
+ data.tar.gz: 8c1feefb9dcb12a136caa168b1107a7c7bf57712cc87f8ad3e6f08703ca334b2
5
5
  SHA512:
6
- metadata.gz: d753b45cef093b96879eef584520ae5be28b8b4f9c0bca5746df13f10310b04c4ff34e53a9daa0e0311eaf9e1a19584f92865dede9721a5b86e7e162d9f6c1c8
7
- data.tar.gz: a4f1d479ce55cec27f0b96392f956d6b9922c68f19469593a9caacb7cc007300d98833be91355dbcea3ec600b26f4c53780d09f4989915223657a8d432bf7e35
6
+ metadata.gz: 93a3a0802cbb6281da84c207c748f410e7a0e9609f70423a0832aab9073298c0d6171b270106f80761928f6433183c93bf91b1755c5c9c37269b5e2ca3e5467c
7
+ data.tar.gz: 2df0a5065089e369c0dbf10733e1aab1c243012a9d9621efd84caa29375d35f6ab254ff4b184fba6469a655a7da5dcf181258e95de010582d66325d728eb97ed
data/.rubocop.yml CHANGED
@@ -28,3 +28,9 @@ Lint/ConstantDefinitionInBlock:
28
28
 
29
29
  Metrics/BlockLength:
30
30
  Enabled: false
31
+
32
+ Metrics/CyclomaticComplexity:
33
+ Max: 14
34
+
35
+ Metrics/MethodLength:
36
+ Max: 25
data/README.md CHANGED
@@ -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
- - [ ] min
97
- - [ ] constraint
98
- - [ ] validator
99
- - [ ] max
100
- - [ ] constraint
101
- - [ ] validator
102
- - [ ] exclusiveMin
103
- - [ ] constraint
104
- - [ ] validator
105
- - [ ] exclusiveMax
106
- - [ ] constraint
107
- - [ ] validator
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.2.0"
5
+ spec.version = "0.3.0"
6
6
  spec.authors = ["Ryota Yoshikawa"]
7
7
  spec.email = ["yoshikawa@topotal.com"]
8
8
 
@@ -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.2.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: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -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.32
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.