rails-param-validation 0.1.2 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f454557e84af9fb83386c6c0cbc2ca4dc107e734694f9372f9773d66a7fb38be
|
4
|
+
data.tar.gz: 1eb7609cf3c6e1c1c492eaaed2a82b8e6a38434fb9e62dabc550c6db5fc37a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48af5864f66cb0268da858d648259bd3098403f6517972a4cf3f44e3fcb5ac728a8e5c20aab6fdb5816a3b6b557a180385d8ab322f947b228531b0830d5469f4
|
7
|
+
data.tar.gz: 0a7afbd9599bf990e0acf73c8650a09cdf2c7716bf0c22e680ad11e19d9133f6af97b8a701647cd738d28921c8eda9c474ccd53952149e992736cd8507d5a425
|
@@ -38,7 +38,9 @@ module RailsParamValidation
|
|
38
38
|
|
39
39
|
if result.matches?
|
40
40
|
# Copy the parameters if the validation succeeded
|
41
|
-
@validated_parameters =
|
41
|
+
@validated_parameters = ActiveSupport::HashWithIndifferentAccess.new(
|
42
|
+
result.value.merge(action: action, controller: controller)
|
43
|
+
)
|
42
44
|
else
|
43
45
|
# Render an appropriate error message
|
44
46
|
_render_invalid_param_response result
|
@@ -50,22 +52,30 @@ module RailsParamValidation
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def _render_invalid_param_response(result)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
if respond_to? :respond_to
|
56
|
+
# Depending on the accept header, choose the way to answer
|
57
|
+
respond_to do |format|
|
58
|
+
format.html do
|
59
|
+
if RailsParamValidation.config.use_default_html_response
|
60
|
+
_create_html_error result
|
61
|
+
else
|
62
|
+
raise ParamValidationFailedError.new(result)
|
63
|
+
end
|
60
64
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
format.json do
|
66
|
+
if RailsParamValidation.config.use_default_json_response
|
67
|
+
_create_json_error result
|
68
|
+
else
|
69
|
+
raise ParamValidationFailedError.new(result)
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
73
|
+
else
|
74
|
+
if RailsParamValidation.config.use_default_json_response
|
75
|
+
_create_json_error result
|
76
|
+
else
|
77
|
+
raise ParamValidationFailedError.new(result)
|
78
|
+
end
|
69
79
|
end
|
70
80
|
end
|
71
81
|
|
@@ -20,6 +20,11 @@ module RailsParamValidation
|
|
20
20
|
ActionController::Base.send :include, AnnotationExtension
|
21
21
|
ActionController::Base.send :include, CustomTypesExtension
|
22
22
|
ActionController::Base.send :extend, RailsParamValidation::Types
|
23
|
+
|
24
|
+
ActionController::API.send :include, ActionControllerExtension
|
25
|
+
ActionController::API.send :include, AnnotationExtension
|
26
|
+
ActionController::API.send :include, CustomTypesExtension
|
27
|
+
ActionController::API.send :extend, RailsParamValidation::Types
|
23
28
|
end
|
24
29
|
|
25
30
|
rake_tasks do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-param-validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oskar Kirmis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Declarative parameter definition and validation for Rails
|
14
14
|
email:
|