validate-params 0.15.1 → 0.16.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: 60d5a946fa5aa5e37911a20e0e58da17dad0e4de72c3daddfb3eb61176aa96ad
4
- data.tar.gz: 8115804497bd2bfc46db0d489a361521c878922f6aa53c2cf4b373ce4eb11ff1
3
+ metadata.gz: 77ad49f477340257039775213f6c8ebd6bbaf6eb79ab49b298bd50d6fab88291
4
+ data.tar.gz: 522314281864e41faeea4a67857bd856fe0f02211d0f7ff5c2b84c761b1395da
5
5
  SHA512:
6
- metadata.gz: b28cc35797e7b0f75bc60e8defe55313056f30b6651a29055e62f058d702ab72e3bb0ea6b016162eea8f7426239adf6c7bb0dd3e37c99ca5b0393ebaf5b902b5
7
- data.tar.gz: e24c5f808855274cf47ddab2160af5e24203909520d88be40c1b6b78ced65e26259c116fa5a7908b4da81e187d1b1bd18139489778df1b49544e03dd11916042
6
+ metadata.gz: dec501d625c7a0ff55f23ce26cfec0b504808a6d4ac5b33e584152fb996905873cce9b443701aa6ef3990de2356d4fe16a2384ef7edeb4a24dd6da5f53168d3e
7
+ data.tar.gz: edd03c3b475a23a5f022aba35edf995df6b332aa7e29fb43bac62e62f25393d238b37e0c7dac24075227cfb84e9e1f2d6aa3844fcb312b4f4153dbeb74fcba61
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.16.0] - 2025-11-25
2
+
3
+ - Support `:in` options to Array, of: String
4
+
1
5
  ## [0.15.1] - 2025-10-14
2
6
 
3
7
  - Fixed issue with DateTime type validation to reject timestamps that result in years greater than 9999
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.2"
9
- gem "rubocop", "~> 1.63"
8
+ gem "rake", "~> 13.3"
9
+ gem "rubocop", "~> 1.81"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- validate-params (0.15.1)
4
+ validate-params (0.16.0)
5
5
  activesupport (>= 6.1.0)
6
6
  i18n (>= 1.6)
7
7
 
@@ -27,7 +27,7 @@ GEM
27
27
  minitest (>= 5.1)
28
28
  tzinfo (~> 2.0)
29
29
  zeitwerk (~> 2.3)
30
- ast (2.4.2)
30
+ ast (2.4.3)
31
31
  builder (3.2.4)
32
32
  concurrent-ruby (1.2.3)
33
33
  crass (1.0.6)
@@ -35,8 +35,9 @@ GEM
35
35
  erubi (1.12.0)
36
36
  i18n (1.14.5)
37
37
  concurrent-ruby (~> 1.0)
38
- json (2.7.2)
39
- language_server-protocol (3.17.0.3)
38
+ json (2.16.0)
39
+ language_server-protocol (3.17.0.5)
40
+ lint_roller (1.1.0)
40
41
  loofah (2.21.1)
41
42
  crass (~> 1.0.2)
42
43
  nokogiri (>= 1.5.9)
@@ -45,12 +46,13 @@ GEM
45
46
  nokogiri (1.15.6)
46
47
  mini_portile2 (~> 2.8.2)
47
48
  racc (~> 1.4)
48
- parallel (1.24.0)
49
- parser (3.3.0.5)
49
+ parallel (1.27.0)
50
+ parser (3.3.10.0)
50
51
  ast (~> 2.4.1)
51
52
  racc
52
- racc (1.7.3)
53
- rack (2.2.9)
53
+ prism (1.6.0)
54
+ racc (1.8.1)
55
+ rack (2.2.20)
54
56
  rack-test (2.1.0)
55
57
  rack (>= 1.3)
56
58
  rails-dom-testing (2.0.3)
@@ -59,9 +61,8 @@ GEM
59
61
  rails-html-sanitizer (1.5.0)
60
62
  loofah (~> 2.19, >= 2.19.1)
61
63
  rainbow (3.1.1)
62
- rake (13.2.1)
63
- regexp_parser (2.9.0)
64
- rexml (3.2.8)
64
+ rake (13.3.1)
65
+ regexp_parser (2.11.3)
65
66
  rspec (3.13.0)
66
67
  rspec-core (~> 3.13.0)
67
68
  rspec-expectations (~> 3.13.0)
@@ -75,23 +76,26 @@ GEM
75
76
  diff-lcs (>= 1.2.0, < 2.0)
76
77
  rspec-support (~> 3.13.0)
77
78
  rspec-support (3.13.0)
78
- rubocop (1.63.3)
79
+ rubocop (1.81.7)
79
80
  json (~> 2.3)
80
- language_server-protocol (>= 3.17.0)
81
+ language_server-protocol (~> 3.17.0.2)
82
+ lint_roller (~> 1.1.0)
81
83
  parallel (~> 1.10)
82
84
  parser (>= 3.3.0.2)
83
85
  rainbow (>= 2.2.2, < 4.0)
84
- regexp_parser (>= 1.8, < 3.0)
85
- rexml (>= 3.2.5, < 4.0)
86
- rubocop-ast (>= 1.31.1, < 2.0)
86
+ regexp_parser (>= 2.9.3, < 3.0)
87
+ rubocop-ast (>= 1.47.1, < 2.0)
87
88
  ruby-progressbar (~> 1.7)
88
- unicode-display_width (>= 2.4.0, < 3.0)
89
- rubocop-ast (1.31.2)
90
- parser (>= 3.3.0.4)
89
+ unicode-display_width (>= 2.4.0, < 4.0)
90
+ rubocop-ast (1.48.0)
91
+ parser (>= 3.3.7.2)
92
+ prism (~> 1.4)
91
93
  ruby-progressbar (1.13.0)
92
94
  tzinfo (2.0.6)
93
95
  concurrent-ruby (~> 1.0)
94
- unicode-display_width (2.5.0)
96
+ unicode-display_width (3.2.0)
97
+ unicode-emoji (~> 4.1)
98
+ unicode-emoji (4.1.0)
95
99
  zeitwerk (2.6.8)
96
100
 
97
101
  PLATFORMS
@@ -100,9 +104,9 @@ PLATFORMS
100
104
  DEPENDENCIES
101
105
  actionpack (>= 6.1.0)
102
106
  bundler (~> 2.0)
103
- rake (~> 13.2)
107
+ rake (~> 13.3)
104
108
  rspec (~> 3.0)
105
- rubocop (~> 1.63)
109
+ rubocop (~> 1.81)
106
110
  validate-params!
107
111
 
108
112
  BUNDLED WITH
@@ -3,5 +3,6 @@ en:
3
3
  required: "%{param} is required"
4
4
  invalid_type: "%{param} must be a valid %{type}"
5
5
  invalid_in: "%{param} is an invalid value"
6
+ array_invalid_in: "%{param} has an invalid values: %{values}"
6
7
  more_than_max: "%{param} cannot be more than maximum"
7
8
  less_than_min: "%{param} cannot be less than minimum"
@@ -38,9 +38,12 @@ module ValidateParams
38
38
  end
39
39
 
40
40
  def array
41
- return if Types::Array.valid?(@value, **@options)
41
+ unless Types::Array.valid?(@value, **@options)
42
+ @errors << { message: error_message }
43
+ return
44
+ end
42
45
 
43
- @errors << { message: error_message }
46
+ array_validate_inclusion if @options[:in].present?
44
47
  end
45
48
 
46
49
  def date
@@ -124,6 +127,16 @@ module ValidateParams
124
127
  }
125
128
  end
126
129
 
130
+ def array_validate_inclusion
131
+ extra_values = Types::Array.cast(@value, **@options) - @options[:in]
132
+ return if extra_values.empty?
133
+
134
+ @errors << {
135
+ message: I18n.t("validate_params.array_invalid_in", param: error_param_name, values: extra_values),
136
+ valid_values: @options[:in]
137
+ }
138
+ end
139
+
127
140
  def validate_min(value)
128
141
  min_value = @options[:min].is_a?(Proc) ? @options[:min].call : @options[:min]
129
142
  return if min_value <= value
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ValidateParams
4
- VERSION = "0.15.1"
4
+ VERSION = "0.16.0"
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.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dcherevatenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-16 00:00:00.000000000 Z
11
+ date: 2025-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack