stronger_parameters 2.19.1 → 2.20.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: 6b498cb065e3370fff5def0735395b8b396565f62e76364612f7ab101ecc3c63
4
- data.tar.gz: 7edd672e06906c24efc86aff49783659df49e390918693dcf1c2dab174dfb8b2
3
+ metadata.gz: f186917c03263aba1f50d3e3ac7ff3acd4926655f8e9112b7385b34918fdb099
4
+ data.tar.gz: 863fc50ff7e443536ad62de00470439b3b4cfa4288174100db0e154bba9064c9
5
5
  SHA512:
6
- metadata.gz: 1d17d12e4b23862fd3dd7d6663a660d26324f29c392e7af6577c4792d0df53c01c20f45a8a99c6b8a57870c43650a580d9f57796528624450e8b59e7482d4cb1
7
- data.tar.gz: aa06279656cb6ebc52e133e1f7a0d61fe439b0bf88b9e6e6521898cec61986c6799f1b0ce63d70f0a1edb7f3eb7005fc19103606df44fc6f765c17e73bb3bdd9
6
+ metadata.gz: ccafbf30f5050cc5eb2f3d9340d295197cffe2e183e382a2c16f3acd291f4529695ed5ef110fa742f9e19e3ce6ab950fa8a4364fc5557808c16b3635791a8418
7
+ data.tar.gz: b1bbeb6bb9368094ed661f35eb2d4fbabe719ee81e004b7a6abf40b2dd7d45de4904a1d2ebd52ed780ba230c2c50db6e094a7f50b0cdeb6a009de4ca045e1b91
data/README.md CHANGED
@@ -271,6 +271,7 @@ curl -I 'http://localhost/api/users/1.json' -X POST -d '{ "user": { "id": 1 } }'
271
271
  | Parameters.file | File, StringIO, Rack::Test::UploadedFile, ActionDispatch::Http::UploadedFile or subclasses |
272
272
  | Parameters.decimal(8,2) | value is a String, Integer or Float with a precision of 9 and scale of 2 |
273
273
  | Parameters.hex | value is a String that matches the hexadecimal format |
274
+ | Parameters.ulid | value is a String of length 26 with only Crockford Base32 symbols |
274
275
 
275
276
  ## Development
276
277
 
@@ -279,8 +280,7 @@ curl -I 'http://localhost/api/users/1.json' -X POST -d '{ "user": { "id": 1 } }'
279
280
  ```
280
281
  git checkout master && git fetch origin && git reset --hard origin/master
281
282
  bundle exec rake bump:<patch|minor|major>
282
- git tag v<tag>
283
- git push --tags
283
+ bundle exec rake release
284
284
  ```
285
285
 
286
286
  [github action](.github/workflows/ruby-gem-publication.yml) will release a new version to rubygems.org
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ require 'stronger_parameters/constraint'
3
+
4
+ module StrongerParameters
5
+ class UlidConstraint < Constraint
6
+ # https://www.crockford.com/base32.html
7
+ INVALID_CHAR_REGEX = /[ilou]|[^a-z0-9]/i.freeze
8
+ ULID_LENGTH = 26
9
+
10
+ def value(v)
11
+ return invalid_value(v) unless v.is_a?(String)
12
+ return invalid_value(v) unless v.length == ULID_LENGTH
13
+ return invalid_value(v) if v =~ INVALID_CHAR_REGEX
14
+
15
+ v
16
+ end
17
+
18
+ private
19
+
20
+ def invalid_value(v)
21
+ StrongerParameters::InvalidValue.new(v, "must be a ULID")
22
+ end
23
+ end
24
+ end
@@ -20,3 +20,4 @@ require 'stronger_parameters/constraints/nil_string_constraint'
20
20
  require 'stronger_parameters/constraints/file_constraint'
21
21
  require 'stronger_parameters/constraints/decimal_constraint'
22
22
  require 'stronger_parameters/constraints/hex_constraint'
23
+ require 'stronger_parameters/constraints/ulid_constraint'
@@ -140,6 +140,10 @@ module StrongerParameters
140
140
  def hex
141
141
  HexConstraint.new
142
142
  end
143
+
144
+ def ulid
145
+ UlidConstraint.new
146
+ end
143
147
  end
144
148
 
145
149
  def hash_filter_with_stronger_parameters(params, filter)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module StrongerParameters
3
- VERSION = '2.19.1'
3
+ VERSION = '2.20.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stronger_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.19.1
4
+ version: 2.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-23 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: mocha
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: forking_test_runner
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +173,7 @@ files:
187
173
  - lib/stronger_parameters/constraints/string_constraint.rb
188
174
  - lib/stronger_parameters/constraints/time_constraint.rb
189
175
  - lib/stronger_parameters/constraints/time_iso8601_constraint.rb
176
+ - lib/stronger_parameters/constraints/ulid_constraint.rb
190
177
  - lib/stronger_parameters/controller_support/permitted_parameters.rb
191
178
  - lib/stronger_parameters/errors.rb
192
179
  - lib/stronger_parameters/parameters.rb