sinatra-param-validator 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1312fa49d8b256875f1c6de21269a7be31ab1c3f2ca0a5efdb9902c31b5406d4
4
- data.tar.gz: 4b483ce648a24026e26964b0cdd358a4f1256ffe7dc810770e8dbf2b98204306
3
+ metadata.gz: 2f824395ffa6b3e38d61c1e4cd81ee2237987c47b04c51abb4cd43d2fdedd2ec
4
+ data.tar.gz: 9294cc7618a05d263df6f7e7415fdab88b0f6e846b05fce4cac2763d8a79b740
5
5
  SHA512:
6
- metadata.gz: 2714270e73581d5beb88eb136516fc1d5275d05ebe2a3c5efca08d54b64bb2bcda467cb45cb4ab3fa7fee063606171356f9fe869cbedc0950afc7b92cb5dc8eb
7
- data.tar.gz: 692691bde5e786c23897080967004fc5fb5b695d49942fd671db69ef6ec91c00771a0afbfc5e69954b5e22f8e585829c8e08a04b6a954cf14ec46b1c19dfdf8c
6
+ metadata.gz: 17ed2207a700e74b5114ac4b10fb9f8a3f6089d6661df044017a5b36ea558ffec2452e62d7ec0814a5ce30536ab039569cfa45f031960e791caaf57ae253afac
7
+ data.tar.gz: 8dd242fdf3f379612962ca5897e23e86782b061b16373bfc3dbf4b6e3e22b95e39787027e1499cca36872c9d88b7246871bbb882f6472caadbd5004de7763be4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2022-06-09
4
+
5
+ - Add `block` to run blocks of code in the route context
6
+
3
7
  ## [0.5.0] - 2022-06-09
4
8
 
5
9
  - Allow the validator to be passed to the block for a valid parameter
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinatra-param-validator (0.5.0)
4
+ sinatra-param-validator (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -118,12 +118,20 @@ with a message, and it will be passed through as an error for the parameter.
118
118
  If you need to do further validation with your parameter, the validator can be passed to the block:
119
119
 
120
120
  ```ruby
121
-
122
121
  param :number, Integer, required: true do |validator|
123
122
  validator.param :digit, Integer, min: params[:number]
124
123
  end
125
124
  ```
126
125
 
126
+ If you need to run some code in the route context, you can just use the `block` keyword:
127
+
128
+ ```ruby
129
+ block do |validator|
130
+ #...
131
+ validator.param :val, Integer
132
+ end
133
+ ```
134
+
127
135
  ## Rules
128
136
 
129
137
  Rules work on multiple parameters:
@@ -24,6 +24,10 @@ module Sinatra
24
24
  @errors[key] = @errors.fetch(key, []).concat(Array(error))
25
25
  end
26
26
 
27
+ def block(&block)
28
+ run_block :block, block
29
+ end
30
+
27
31
  def param(key, type, message: nil, **args, &block)
28
32
  parameter = Parameter.new(@context.params[key], type, **args)
29
33
  @context.params[key] = parameter.coerced if @context.params.key?(key) && parameter.coerced
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sinatra
4
4
  module ParamValidator
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-param-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Selby