validate-params 0.13.0 → 0.14.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: 77ee095dc2316a90b3784532a9d0586777c187b99c63b489129e4c0d6c4c6b2b
4
- data.tar.gz: 17f55ad85601e32c1218f76c0b3e804b83cd5159b41308c0a448431f7a360dfc
3
+ metadata.gz: fae87e49e657c4474eb70cecc2b42f3b8431cd2838539c5892d74d8d6ada70ef
4
+ data.tar.gz: e24d98df25519a3b937aacce314f4a89c50154121277d0f9ea6131bc199e9205
5
5
  SHA512:
6
- metadata.gz: 8a6b277ff7d5d03c8926a9ccf3b6b730bed2527de0e70d44fdc1853e749c6701a0072d39aa3e1679be0a22ae93d72569cff7986ff1b71f1d424c80f2b3831c1e
7
- data.tar.gz: a5001cd005f065d12ffaa16a6f0f97b1148bf5934ea37e2804d6c5b749f7b666116fdb6b060a49babfa84b354dd3f4ce1685e73bd2f56670dcf579338cb1ae42
6
+ metadata.gz: e543564a6a1f9e983a3315a82ca53ec64eba95efaa9937dc01cf0165c0d513173c3e3a5255acced136631cadfcb7154aba5f81b2c885a419e4fef5cc4ed65e88
7
+ data.tar.gz: a2a5c8fb0392f70d0b7d03d06e9d78391c751c676202705dd4ffc2c116f09234ec12a20f3da94d3b285002feb405f91ec39e12703ded3b97a82c631a21723aaa
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
+ ## [0.14.0] - 2024-09-25
2
+
3
+ - Support for Proc as options for `:min` and `:max` to validate param values
4
+
5
+ ## [0.13.1] - 2024-04-22
6
+
7
+ - Improved checking for empty strings
8
+
1
9
  ## [0.13.0] - 2024-04-16
2
10
 
3
11
  - Added `:scrub_invalid_utf8` and `:scrub_invalid_utf8_replacement` options to String type to handle invalid UTF-8 characters
4
12
  - Added [configurator](README.md#configuration) to change default behaviour for certain options
5
13
 
6
-
7
14
  ## [0.12.5] - 2024-04-15
8
15
 
9
16
  - Restrict validation rules for Hash type objects
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in validate_params.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "rubocop", "~> 1.57"
8
+ gem "rake", "~> 13.2"
9
+ gem "rubocop", "~> 1.63"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validate-params (0.13.0)
4
+ validate-params (0.14.0)
5
5
  activesupport (>= 6.1.0)
6
6
  i18n (>= 1.6)
7
7
 
@@ -29,28 +29,28 @@ GEM
29
29
  zeitwerk (~> 2.3)
30
30
  ast (2.4.2)
31
31
  builder (3.2.4)
32
- concurrent-ruby (1.2.2)
32
+ concurrent-ruby (1.2.3)
33
33
  crass (1.0.6)
34
- diff-lcs (1.5.0)
34
+ diff-lcs (1.5.1)
35
35
  erubi (1.12.0)
36
- i18n (1.13.0)
36
+ i18n (1.14.5)
37
37
  concurrent-ruby (~> 1.0)
38
- json (2.6.3)
38
+ json (2.7.2)
39
39
  language_server-protocol (3.17.0.3)
40
40
  loofah (2.21.1)
41
41
  crass (~> 1.0.2)
42
42
  nokogiri (>= 1.5.9)
43
- mini_portile2 (2.8.2)
43
+ mini_portile2 (2.8.6)
44
44
  minitest (5.18.0)
45
- nokogiri (1.14.3)
46
- mini_portile2 (~> 2.8.0)
45
+ nokogiri (1.15.6)
46
+ mini_portile2 (~> 2.8.2)
47
47
  racc (~> 1.4)
48
- parallel (1.23.0)
49
- parser (3.2.2.4)
48
+ parallel (1.24.0)
49
+ parser (3.3.0.5)
50
50
  ast (~> 2.4.1)
51
51
  racc
52
- racc (1.7.1)
53
- rack (2.2.7)
52
+ racc (1.7.3)
53
+ rack (2.2.9)
54
54
  rack-test (2.1.0)
55
55
  rack (>= 1.3)
56
56
  rails-dom-testing (2.0.3)
@@ -59,36 +59,38 @@ GEM
59
59
  rails-html-sanitizer (1.5.0)
60
60
  loofah (~> 2.19, >= 2.19.1)
61
61
  rainbow (3.1.1)
62
- rake (13.0.6)
63
- regexp_parser (2.8.2)
64
- rexml (3.2.6)
65
- rspec (3.12.0)
66
- rspec-core (~> 3.12.0)
67
- rspec-expectations (~> 3.12.0)
68
- rspec-mocks (~> 3.12.0)
69
- rspec-core (3.12.2)
70
- rspec-support (~> 3.12.0)
71
- rspec-expectations (3.12.3)
62
+ rake (13.2.1)
63
+ regexp_parser (2.9.0)
64
+ rexml (3.2.8)
65
+ strscan (>= 3.0.9)
66
+ rspec (3.13.0)
67
+ rspec-core (~> 3.13.0)
68
+ rspec-expectations (~> 3.13.0)
69
+ rspec-mocks (~> 3.13.0)
70
+ rspec-core (3.13.0)
71
+ rspec-support (~> 3.13.0)
72
+ rspec-expectations (3.13.0)
72
73
  diff-lcs (>= 1.2.0, < 2.0)
73
- rspec-support (~> 3.12.0)
74
- rspec-mocks (3.12.5)
74
+ rspec-support (~> 3.13.0)
75
+ rspec-mocks (3.13.0)
75
76
  diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.12.0)
77
- rspec-support (3.12.0)
78
- rubocop (1.57.2)
77
+ rspec-support (~> 3.13.0)
78
+ rspec-support (3.13.0)
79
+ rubocop (1.63.3)
79
80
  json (~> 2.3)
80
81
  language_server-protocol (>= 3.17.0)
81
82
  parallel (~> 1.10)
82
- parser (>= 3.2.2.4)
83
+ parser (>= 3.3.0.2)
83
84
  rainbow (>= 2.2.2, < 4.0)
84
85
  regexp_parser (>= 1.8, < 3.0)
85
86
  rexml (>= 3.2.5, < 4.0)
86
- rubocop-ast (>= 1.28.1, < 2.0)
87
+ rubocop-ast (>= 1.31.1, < 2.0)
87
88
  ruby-progressbar (~> 1.7)
88
89
  unicode-display_width (>= 2.4.0, < 3.0)
89
- rubocop-ast (1.30.0)
90
- parser (>= 3.2.1.0)
90
+ rubocop-ast (1.31.2)
91
+ parser (>= 3.3.0.4)
91
92
  ruby-progressbar (1.13.0)
93
+ strscan (3.1.0)
92
94
  tzinfo (2.0.6)
93
95
  concurrent-ruby (~> 1.0)
94
96
  unicode-display_width (2.5.0)
@@ -100,9 +102,9 @@ PLATFORMS
100
102
  DEPENDENCIES
101
103
  actionpack (>= 6.1.0)
102
104
  bundler (~> 2.0)
103
- rake (~> 13.0)
105
+ rake (~> 13.2)
104
106
  rspec (~> 3.0)
105
- rubocop (~> 1.57)
107
+ rubocop (~> 1.63)
106
108
  validate-params!
107
109
 
108
110
  BUNDLED WITH
data/README.md CHANGED
@@ -20,7 +20,9 @@ If bundler is not being used to manage dependencies, install the gem by executin
20
20
  To configure default options, create `config/initializers/validate_params.rb` file. Configuration example:
21
21
 
22
22
  ```ruby
23
- Rails.application.config.after_initialize do
23
+ require "validate_params/validatable"
24
+
25
+ Rails.application.config.before_initialize do
24
26
  ValidateParams::Validatable.configure do |config|
25
27
  config.scrub_invalid_utf8 = true # Default: false
26
28
  config.scrub_invalid_utf8_replacement = "�" # Default: empty string
@@ -10,7 +10,7 @@ module ValidateParams
10
10
  def to_h
11
11
  {
12
12
  scrub_invalid_utf8: scrub_invalid_utf8,
13
- scrub_invalid_utf8_replacement: scrub_invalid_utf8_replacement,
13
+ scrub_invalid_utf8_replacement: scrub_invalid_utf8_replacement
14
14
  }
15
15
  end
16
16
  end
@@ -20,7 +20,7 @@ module ValidateParams
20
20
  end
21
21
 
22
22
  def call
23
- return if @value.blank? && !@options[:required]
23
+ return if @value.nil? && !@options[:required]
24
24
 
25
25
  if @value.blank? && @options[:required]
26
26
  @errors << { message: required_error_message }
@@ -119,20 +119,22 @@ module ValidateParams
119
119
  end
120
120
 
121
121
  def validate_min(value)
122
- return if @options[:min] <= value
122
+ min_value = @options[:min].is_a?(Proc) ? @options[:min].call : @options[:min]
123
+ return if min_value <= value
123
124
 
124
125
  @errors << {
125
126
  message: I18n.t("validate_params.less_than_min", param: error_param_name),
126
- min: @options[:min]
127
+ min: min_value
127
128
  }
128
129
  end
129
130
 
130
131
  def validate_max(value)
131
- return if @options[:max] >= value
132
+ max_value = @options[:max].is_a?(Proc) ? @options[:max].call : @options[:max]
133
+ return if max_value >= value
132
134
 
133
135
  @errors << {
134
136
  message: I18n.t("validate_params.more_than_max", param: error_param_name),
135
- max: @options[:max]
137
+ max: max_value
136
138
  }
137
139
  end
138
140
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ValidateParams
4
- VERSION = "0.13.0"
4
+ VERSION = "0.14.0"
5
5
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "actionpack", ">= 6.1.0"
28
28
  spec.add_development_dependency "bundler", "~> 2.0"
29
- spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rake", "~> 13.2"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
31
 
32
32
  spec.add_dependency "activesupport", ">= 6.1.0"
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.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dcherevatenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-18 00:00:00.000000000 Z
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +103,7 @@ extra_rdoc_files: []
103
103
  files:
104
104
  - ".rspec"
105
105
  - ".rubocop.yml"
106
+ - ".ruby-version"
106
107
  - CHANGELOG.md
107
108
  - Gemfile
108
109
  - Gemfile.lock
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  - !ruby/object:Gem::Version
147
148
  version: '0'
148
149
  requirements: []
149
- rubygems_version: 3.3.26
150
+ rubygems_version: 3.5.11
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: Gem to validate params in controllers