stronger_parameters 2.19.1 → 2.21.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/stronger_parameters/constraints/hex_constraint.rb +1 -1
- data/lib/stronger_parameters/constraints/ulid_constraint.rb +24 -0
- data/lib/stronger_parameters/constraints.rb +1 -0
- data/lib/stronger_parameters/parameters.rb +4 -0
- data/lib/stronger_parameters/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08f7fbaf510502c324917559ee5bea3177bc04abb9c93ed59e408d772fcbee32'
|
4
|
+
data.tar.gz: a655970b866a445f811b4cba4a26eaab7fe580f0b670cbcd762fa9807e52b7dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41de802ed59bf10a2393ede678806de86b10fdc29c58776d2c688b2b83425edce379e519d19a0f6132524f15638662c492868e63307489e8832c19700bc1e3e4
|
7
|
+
data.tar.gz: 01607efd231b10b2a9d903c5187d1df681b1d049be4568afbf9139ead17b1d5ec0b00682b7cfa5acf78d57405617613f887581d49d016b7731798bff07d2dcbc
|
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
|
-
|
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
|
@@ -4,7 +4,7 @@ require 'stronger_parameters/constraint'
|
|
4
4
|
module StrongerParameters
|
5
5
|
class HexConstraint < Constraint
|
6
6
|
def value(v)
|
7
|
-
return v if v
|
7
|
+
return v if v.is_a?(String) && v.match?(/\A[a-f0-9]+\z/i)
|
8
8
|
|
9
9
|
InvalidValue.new(v, 'must be a hexadecimal string')
|
10
10
|
end
|
@@ -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'
|
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.
|
4
|
+
version: 2.21.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-10 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
|