validate-params 0.12.4 → 0.12.5

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: 49259451d9cfaab7442c2efbebcf863fd95ffaa5939d20bfda60f74a790ebcde
4
- data.tar.gz: 93b889e507e6a14faa28715ce53fc0a8609dd4903a7b1400a4398fad401d9105
3
+ metadata.gz: a0efef56bcd7c8b05e33859d21078422a2a772d3dbb8241a9d0a0e5818c085a6
4
+ data.tar.gz: 23936b451c39e8b6425498c75383b4742ab8e43850f83960aeb200846d59dd32
5
5
  SHA512:
6
- metadata.gz: feb837f5b782d6aa7715b8cc4f508a4c5280221ce4760e818c7b39e10955340db62aaad82ac512257ac01071ca66f6b7246af7de8f4570e3f130acf78a74a7c3
7
- data.tar.gz: 80276c1107d9fd4395b4e3e9cd9bc0fa472b5ea22eedd3303e26521650e7bb25ae56d37285641ace765c6d9f8765345e9b0117538c070be71a83dac64e425b77
6
+ metadata.gz: 963d02b70917dfb1c81dbe672c62ff750c3ed76ae39943eb719e8385b90cf53e588c0d4599cff3551b367650f43a3f0b88cc975a7147e3a3f6f934670f99092f
7
+ data.tar.gz: 1ef4c60aba7a23cff17ad899ebe6996b77312203a0a5c11509dcc53bf66c6cd4801eb03d4af63e5fefcae4ce086de115e919c2e11b15390bd81d9a15c409d7e6
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## [0.12.3] - 2024-04-14
1
+ ## [0.12.5] - 2024-04-15
2
+
3
+ - Restrict validation rules for Hash type objects
4
+
5
+ ## [0.12.4] - 2024-04-14
2
6
 
3
7
  - Revert 0.12.2 changes
4
8
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validate-params (0.12.4)
4
+ validate-params (0.12.5)
5
5
  activesupport (>= 6.1.0)
6
6
  i18n (>= 1.6)
7
7
 
@@ -14,9 +14,9 @@ module ValidateParams
14
14
  if children.any?
15
15
  case type.to_s
16
16
  when "Hash"
17
- # Skip in case hash is configured and string is passed
18
- if !value.is_a?(String)
19
- children.each { |c| c.valid?(value&.[](c.field), errors) }
17
+ children.each do |child|
18
+ child_value = value[child.field] if value.is_a?(Hash) || value.is_a?(ActionController::Parameters)
19
+ child.valid?(child_value, errors)
20
20
  end
21
21
  when "Array"
22
22
  values = value ? Array.wrap(value) : [nil]
@@ -30,6 +30,12 @@ module ValidateParams
30
30
  end
31
31
 
32
32
  private
33
+ def hash
34
+ return if @value.is_a?(Hash) || @value.is_a?(ActionController::Parameters)
35
+
36
+ @errors << { message: error_message }
37
+ end
38
+
33
39
  def array
34
40
  return if Types::Array.valid?(@value, **@options)
35
41
 
@@ -79,9 +79,6 @@ module ValidateParams
79
79
  apply_default_values(sub_params, sub_validation)
80
80
  end
81
81
  elsif validation.type == Hash
82
- # Skip in case hash is configured and string is passed
83
- next if params[validation.field].is_a?(String)
84
-
85
82
  params[validation.field] ||= {}
86
83
  apply_default_values(params[validation.field], sub_validation)
87
84
  else
@@ -108,9 +105,6 @@ module ValidateParams
108
105
 
109
106
  validation.children.each do |sub_validation|
110
107
  if validation.type == Hash
111
- # Skip in case hash is configured and string is passed
112
- next if params[validation.field].is_a?(String)
113
-
114
108
  cast_param_values(params[validation.field], sub_validation)
115
109
  elsif validation.type == Array
116
110
  params[validation.field].each do |sub_params|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ValidateParams
4
- VERSION = "0.12.4"
4
+ VERSION = "0.12.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate-params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - dcherevatenko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-14 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -124,11 +124,11 @@ files:
124
124
  - lib/validate_params/version.rb
125
125
  - sig/validate_params.rbs
126
126
  - validate_params.gemspec
127
- homepage:
127
+ homepage:
128
128
  licenses:
129
129
  - MIT
130
130
  metadata: {}
131
- post_install_message:
131
+ post_install_message:
132
132
  rdoc_options: []
133
133
  require_paths:
134
134
  - lib
@@ -143,8 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.4.10
147
- signing_key:
146
+ rubygems_version: 3.3.26
147
+ signing_key:
148
148
  specification_version: 4
149
149
  summary: Gem to validate params in controllers
150
150
  test_files: []