validate-params 0.12.2 → 0.12.4

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: 2c090bcb2c38160021c65ed02c85fb8f492bd9e7c8bd75790edb9e7ab4fa51f2
4
- data.tar.gz: 5ef867403817bae733d94b187e479a133c06d4f9ef201074ee0a7098710aef70
3
+ metadata.gz: 49259451d9cfaab7442c2efbebcf863fd95ffaa5939d20bfda60f74a790ebcde
4
+ data.tar.gz: 93b889e507e6a14faa28715ce53fc0a8609dd4903a7b1400a4398fad401d9105
5
5
  SHA512:
6
- metadata.gz: bce24ad9959b5d8399b532b25a0b19b07193f0d6dbae474dc4fc0d226cde94aa3258bf394ab82cde6445805f1ae94cd2d7947d7a68eadc421eec77b2112e431b
7
- data.tar.gz: 97cd65a1c24541c3b1b4be12471a6ed7ca57aeebb15bbb467f3c6a097ff63ef81eaf50e64f9dcda79d48db02a87fbfcdf5f5e18b5ed19219e750b9b99c21b88b
6
+ metadata.gz: feb837f5b782d6aa7715b8cc4f508a4c5280221ce4760e818c7b39e10955340db62aaad82ac512257ac01071ca66f6b7246af7de8f4570e3f130acf78a74a7c3
7
+ data.tar.gz: 80276c1107d9fd4395b4e3e9cd9bc0fa472b5ea22eedd3303e26521650e7bb25ae56d37285641ace765c6d9f8765345e9b0117538c070be71a83dac64e425b77
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## [Unreleased]
1
+ ## [0.12.3] - 2024-04-14
2
+
3
+ - Revert 0.12.2 changes
4
+
5
+ ## [0.12.3] - 2024-04-14
6
+
7
+ - Default option for Integer type should support empty string as well
2
8
 
3
9
  ## [0.11.0] - 2023-11-04
4
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validate-params (0.12.2)
4
+ validate-params (0.12.4)
5
5
  activesupport (>= 6.1.0)
6
6
  i18n (>= 1.6)
7
7
 
@@ -23,29 +23,6 @@ module ValidateParams
23
23
  class_methods do
24
24
  attr_reader :params_validations
25
25
 
26
- # When controller inherits from other controller, we need to copy the validations.
27
- #
28
- # Usage example:
29
- #
30
- # class ParentController < ApplicationController
31
- # validate_params_for :index do |p|
32
- # p.param :param1, Integer, min: 1, max: 10
33
- # p.param :param2, Integer, min: 10, max: 20
34
- # end
35
- # end
36
- #
37
- # class ChildController < ParentController
38
- # validate_params_for :index do |p|
39
- # p.param :param1, Integer, min: 0, max: 5
40
- # end
41
- # end
42
- #
43
- # Here in ChildController, the param1 validation will be overridden, but validation for param2 will remain unchanged.
44
- #
45
- def inherited(child)
46
- child.instance_variable_set("@params_validations", @params_validations.deep_dup)
47
- end
48
-
49
26
  def validate_params_for(action, options = {})
50
27
  options[:format] ||= :json
51
28
  @params_validations ||= {}
@@ -118,7 +95,12 @@ module ValidateParams
118
95
  return if !options.key?(:default)
119
96
 
120
97
  value = options[:default].is_a?(Proc) ? options[:default].call : options[:default]
121
- params[validation.field] ||= value
98
+
99
+ if validation.type == Integer
100
+ params[validation.field] = value if params[validation.field].blank?
101
+ else
102
+ params[validation.field] ||= value
103
+ end
122
104
  end
123
105
 
124
106
  def cast_param_values(params, validation)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ValidateParams
4
- VERSION = "0.12.2"
4
+ VERSION = "0.12.4"
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.2
4
+ version: 0.12.4
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-11 00:00:00.000000000 Z
11
+ date: 2024-04-14 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.3.26
147
- signing_key:
146
+ rubygems_version: 3.4.10
147
+ signing_key:
148
148
  specification_version: 4
149
149
  summary: Gem to validate params in controllers
150
150
  test_files: []