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: 48a1fa3f1a48672b525b0d690217217a0d3552168d0a8abe2ec6b60e57c179a5
4
- data.tar.gz: 024efd90c1662104364b1d66047f96b505520b8938e39533f999c269ca09b038
3
+ metadata.gz: f454557e84af9fb83386c6c0cbc2ca4dc107e734694f9372f9773d66a7fb38be
4
+ data.tar.gz: 1eb7609cf3c6e1c1c492eaaed2a82b8e6a38434fb9e62dabc550c6db5fc37a0b
5
5
  SHA512:
6
- metadata.gz: c8025d62a6b23ee1526dc3b2f94592b51a3b37cc5e194122f4fa259bd3ca2f47b617fe149fb656ad0abfa6f773c003984246dd5e5b8c782c770ac94d7477478e
7
- data.tar.gz: 13e08dda8a5baa630e3a808c3a37d7c24f8fc4b13959e0aa3131ef05f473b3eab6859dd37927604727419308a5fe3a16d4f6b0848082bdfb41786fc21c14f4ba
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 = result.value.merge(action: action, controller: controller)
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
- # Depending on the accept header, choose the way to answer
54
- respond_to do |format|
55
- format.html do
56
- if RailsParamValidation.config.use_default_html_response
57
- _create_html_error result
58
- else
59
- raise ParamValidationFailedError.new(result)
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
- end
62
- format.json do
63
- if RailsParamValidation.config.use_default_json_response
64
- _create_json_error result
65
- else
66
- raise ParamValidationFailedError.new(result)
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
@@ -1,3 +1,3 @@
1
1
  module RailsParamValidation
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.2
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-04-21 00:00:00.000000000 Z
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: