api-regulator 0.1.22 → 0.1.23
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/api_regulator/controller_mixin.rb +15 -3
- data/lib/api_regulator/validator.rb +5 -0
- data/lib/api_regulator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2954fc88571b8b3d2086405b0b6973f0202debe1284408531b4a079ba9d86c9c
|
4
|
+
data.tar.gz: 0267527b762872e05fe3a84d7145e39958f4616240dc590d3e10f3996650d387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '06548a9e1bce09a019c2c0e105e3bf34aeabd737dc5f4f802ae3903c0dc0eaae3dfaf841d75d1624948dfc90f465909d6807764a83d6a70c9b9b4922c2c828a9'
|
7
|
+
data.tar.gz: d6a151ef312d62ab88bddc1875645fac23945ed37b5afc0fecb8494700e1443849f38172c89c94434c3ecacb413391078bdffd9e2177417bd629cc02559e1c9f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
api-regulator (0.1.
|
4
|
+
api-regulator (0.1.23)
|
5
5
|
activemodel (~> 8.0)
|
6
6
|
activesupport (~> 8.0)
|
7
7
|
|
@@ -204,7 +204,7 @@ GEM
|
|
204
204
|
timeout (0.4.3)
|
205
205
|
tzinfo (2.0.6)
|
206
206
|
concurrent-ruby (~> 1.0)
|
207
|
-
uri (1.0.
|
207
|
+
uri (1.0.3)
|
208
208
|
useragent (0.16.11)
|
209
209
|
websocket-driver (0.7.7)
|
210
210
|
base64
|
@@ -38,12 +38,24 @@ module ApiRegulator
|
|
38
38
|
body_params = api_definition.params.select(&:body?)
|
39
39
|
permitted_body = body_params.each_with_object({}) do |param, hash|
|
40
40
|
case param.type
|
41
|
-
when :array
|
41
|
+
when :array
|
42
|
+
allowed_params = [build_permitted_keys(param.children)]
|
43
|
+
|
44
|
+
if param.required?
|
45
|
+
nested = params.expect(param.name => allowed_params).map { |set| set.to_h.symbolize_keys }
|
46
|
+
hash[param.name.to_sym] = nested
|
47
|
+
else
|
48
|
+
nested = params.permit(param.name => allowed_params).map { |set| set.to_h.symbolize_keys }
|
49
|
+
hash.merge!(nested)
|
50
|
+
end
|
51
|
+
when :object
|
52
|
+
allowed_params = build_permitted_keys(param.children)
|
53
|
+
|
42
54
|
if param.required?
|
43
|
-
nested = params.expect(param.name =>
|
55
|
+
nested = params.expect(param.name => allowed_params).to_h.symbolize_keys
|
44
56
|
hash[param.name.to_sym] = nested
|
45
57
|
else
|
46
|
-
nested = params.permit(param.name =>
|
58
|
+
nested = params.permit(param.name => allowed_params).to_h.symbolize_keys
|
47
59
|
hash.merge!(nested)
|
48
60
|
end
|
49
61
|
else
|
@@ -124,6 +124,11 @@ module ApiRegulator
|
|
124
124
|
return
|
125
125
|
end
|
126
126
|
|
127
|
+
if max = param.options.dig(:length, :maximum)
|
128
|
+
errors.add(attribute, "must have a max size of #{max}") if raw_value.length > max
|
129
|
+
return
|
130
|
+
end
|
131
|
+
|
127
132
|
raw_value.each_with_index do |value, index|
|
128
133
|
unless value.is_a?(Hash) || value.is_a?(ActionController::Parameters)
|
129
134
|
errors.add("#{attribute}[#{index}]", "must be a hash")
|