sinatra-validation 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +7 -0
- data/example/Gemfile.lock +28 -40
- data/example/app.rb +18 -0
- data/lib/sinatra/validation/version.rb +1 -1
- data/lib/sinatra/validation.rb +9 -1
- data/sinatra-validation.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3a3b73cd49ac6a0b7b6e8aa3c4398e40dae9abb464a59ecc2dec9952ac3f23
|
4
|
+
data.tar.gz: 1d4a20b3554ed689d80b4dd524e1fd6aebf6e315c7e5de45c905f3d7faae379c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54e9deffe50aa5f7e3b5a660a84b777881fc1829083a0d8f16c02cd2d204d3072d835f937d4e2013643b258883d49461f3343678e0bda3d10b1ac47a2c5bc195
|
7
|
+
data.tar.gz: b542a570e3ea3a817230c759630f49a37b22ce34b8c12e3019377acc0add144446313eac1b23f647e9caac12f6457be5253d1088e37956f62e621b7922c631c6
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.6
|
data/README.md
CHANGED
@@ -89,6 +89,13 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
89
89
|
|
90
90
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
91
91
|
|
92
|
+
### Test
|
93
|
+
|
94
|
+
```bash
|
95
|
+
$ bundle install
|
96
|
+
$ rake
|
97
|
+
```
|
98
|
+
|
92
99
|
## Contributing
|
93
100
|
|
94
101
|
Bug reports and pull requests are welcome on GitHub at https://github.com/IzumiSy/sinatra-validation. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/example/Gemfile.lock
CHANGED
@@ -1,65 +1,57 @@
|
|
1
1
|
PATH
|
2
|
-
remote: /Users/
|
2
|
+
remote: /Users/izumi/Devs/sinatra-validation
|
3
3
|
specs:
|
4
|
-
sinatra-validation (0.3.
|
4
|
+
sinatra-validation (0.3.2)
|
5
5
|
dry-validation (~> 1.3)
|
6
6
|
rack (>= 2.0.6)
|
7
|
-
sinatra (~> 2.0
|
7
|
+
sinatra (~> 2.1.0)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
concurrent-ruby (1.1.
|
13
|
-
dry-configurable (0.
|
12
|
+
concurrent-ruby (1.1.9)
|
13
|
+
dry-configurable (0.13.0)
|
14
14
|
concurrent-ruby (~> 1.0)
|
15
|
-
dry-core (~> 0.
|
16
|
-
|
17
|
-
dry-container (0.7.2)
|
15
|
+
dry-core (~> 0.6)
|
16
|
+
dry-container (0.9.0)
|
18
17
|
concurrent-ruby (~> 1.0)
|
19
|
-
dry-configurable (~> 0.
|
20
|
-
dry-core (0.
|
18
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
19
|
+
dry-core (0.7.1)
|
21
20
|
concurrent-ruby (~> 1.0)
|
22
|
-
dry-
|
23
|
-
dry-
|
24
|
-
dry-
|
25
|
-
dry-logic (1.0.6)
|
21
|
+
dry-inflector (0.2.1)
|
22
|
+
dry-initializer (3.0.4)
|
23
|
+
dry-logic (1.2.0)
|
26
24
|
concurrent-ruby (~> 1.0)
|
27
|
-
dry-core (~> 0.
|
28
|
-
|
29
|
-
dry-schema (1.5.0)
|
25
|
+
dry-core (~> 0.5, >= 0.5)
|
26
|
+
dry-schema (1.8.0)
|
30
27
|
concurrent-ruby (~> 1.0)
|
31
|
-
dry-configurable (~> 0.
|
32
|
-
dry-core (~> 0.
|
33
|
-
dry-equalizer (~> 0.2)
|
28
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
29
|
+
dry-core (~> 0.5, >= 0.5)
|
34
30
|
dry-initializer (~> 3.0)
|
35
31
|
dry-logic (~> 1.0)
|
36
|
-
dry-types (~> 1.
|
37
|
-
dry-types (1.
|
32
|
+
dry-types (~> 1.5)
|
33
|
+
dry-types (1.5.1)
|
38
34
|
concurrent-ruby (~> 1.0)
|
39
35
|
dry-container (~> 0.3)
|
40
|
-
dry-core (~> 0.
|
41
|
-
dry-equalizer (~> 0.3)
|
36
|
+
dry-core (~> 0.5, >= 0.5)
|
42
37
|
dry-inflector (~> 0.1, >= 0.1.2)
|
43
38
|
dry-logic (~> 1.0, >= 1.0.2)
|
44
|
-
dry-validation (1.
|
39
|
+
dry-validation (1.7.0)
|
45
40
|
concurrent-ruby (~> 1.0)
|
46
41
|
dry-container (~> 0.7, >= 0.7.1)
|
47
|
-
dry-core (~> 0.
|
48
|
-
dry-equalizer (~> 0.2)
|
42
|
+
dry-core (~> 0.5, >= 0.5)
|
49
43
|
dry-initializer (~> 3.0)
|
50
|
-
dry-schema (~> 1.
|
44
|
+
dry-schema (~> 1.8, >= 1.8.0)
|
51
45
|
mustermann (1.1.1)
|
52
46
|
ruby2_keywords (~> 0.0.1)
|
53
|
-
rack (2.2.
|
54
|
-
rack-
|
55
|
-
rack (~> 2.0)
|
56
|
-
rack-protection (2.0.8.1)
|
47
|
+
rack (2.2.3)
|
48
|
+
rack-protection (2.1.0)
|
57
49
|
rack
|
58
|
-
ruby2_keywords (0.0.
|
59
|
-
sinatra (2.0
|
50
|
+
ruby2_keywords (0.0.5)
|
51
|
+
sinatra (2.1.0)
|
60
52
|
mustermann (~> 1.0)
|
61
|
-
rack (~> 2.
|
62
|
-
rack-protection (= 2.0
|
53
|
+
rack (~> 2.2)
|
54
|
+
rack-protection (= 2.1.0)
|
63
55
|
tilt (~> 2.0)
|
64
56
|
tilt (2.0.10)
|
65
57
|
|
@@ -67,12 +59,8 @@ PLATFORMS
|
|
67
59
|
ruby
|
68
60
|
|
69
61
|
DEPENDENCIES
|
70
|
-
rack-contrib
|
71
62
|
sinatra
|
72
63
|
sinatra-validation!
|
73
64
|
|
74
|
-
RUBY VERSION
|
75
|
-
ruby 2.6.6p146
|
76
|
-
|
77
65
|
BUNDLED WITH
|
78
66
|
1.17.2
|
data/example/app.rb
CHANGED
@@ -58,4 +58,22 @@ class Application < Sinatra::Base
|
|
58
58
|
halt 500, 'invalid'
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
get '/filter' do
|
63
|
+
validates filter_unpermitted_params: true do
|
64
|
+
params do
|
65
|
+
optional(:allowed).filled(:str?)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
params.map{|k, v| "#{k}=#{v}"}.join(' ')
|
69
|
+
end
|
70
|
+
|
71
|
+
get '/result' do
|
72
|
+
result = validates do
|
73
|
+
params do
|
74
|
+
optional(:allowed).filled(:str?)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
result.params.map{|k, v| "#{k}=#{v}"}.join(' ')
|
78
|
+
end
|
61
79
|
end
|
data/lib/sinatra/validation.rb
CHANGED
@@ -28,7 +28,12 @@ module Sinatra
|
|
28
28
|
def validates(options = {}, &block)
|
29
29
|
schema = Class.new(Dry::Validation::Contract, &block).new
|
30
30
|
validation = schema.call(params)
|
31
|
-
result = Result.new(
|
31
|
+
result = Result.new(Sinatra::IndifferentHash[validation.to_h])
|
32
|
+
.with_message(validation.errors)
|
33
|
+
|
34
|
+
if options[:filter_unpermitted_params] || settings.filter_unpermitted_params
|
35
|
+
params.replace validation.to_h
|
36
|
+
end
|
32
37
|
|
33
38
|
if options[:silent] || settings.silent_validation
|
34
39
|
return result
|
@@ -37,6 +42,8 @@ module Sinatra
|
|
37
42
|
if validation.failure?
|
38
43
|
raise InvalidParameterError.new(result)
|
39
44
|
end
|
45
|
+
|
46
|
+
result
|
40
47
|
rescue InvalidParameterError => exception
|
41
48
|
if options[:raise] || settings.raise_sinatra_validation_exception
|
42
49
|
raise exception
|
@@ -57,6 +64,7 @@ module Sinatra
|
|
57
64
|
app.helpers Validation::Helpers
|
58
65
|
app.set :silent_validation, false
|
59
66
|
app.set :raise_sinatra_validation_exception, false
|
67
|
+
app.set :filter_unpermitted_params, false
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
data/sinatra-validation.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency 'sinatra', '~> 2.0
|
24
|
+
spec.add_dependency 'sinatra', '~> 2.1.0'
|
25
25
|
spec.add_dependency 'rack', '>= 2.0.6'
|
26
26
|
spec.add_dependency 'dry-validation', '~> 1.3'
|
27
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IzumiSy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: 2.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: 2.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".circleci/config.yml"
|
133
133
|
- ".gitignore"
|
134
134
|
- ".rspec"
|
135
|
+
- ".ruby-version"
|
135
136
|
- CODE_OF_CONDUCT.md
|
136
137
|
- Gemfile
|
137
138
|
- LICENSE.txt
|
@@ -150,7 +151,7 @@ homepage: https://github.com/IzumiSy/sinatra-validation
|
|
150
151
|
licenses:
|
151
152
|
- MIT
|
152
153
|
metadata: {}
|
153
|
-
post_install_message:
|
154
|
+
post_install_message:
|
154
155
|
rdoc_options: []
|
155
156
|
require_paths:
|
156
157
|
- lib
|
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
167
|
version: '0'
|
167
168
|
requirements: []
|
168
169
|
rubygems_version: 3.0.3
|
169
|
-
signing_key:
|
170
|
+
signing_key:
|
170
171
|
specification_version: 4
|
171
172
|
summary: '"Sinatra extension for request parameter validation"'
|
172
173
|
test_files: []
|