data-validator 1.1.2 → 1.1.3

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
- SHA1:
3
- metadata.gz: 30f52452dbb7b555d9d1f9730387db0bfb16295c
4
- data.tar.gz: 3ce763214022495c6f36e43185cef9a442280c23
2
+ SHA256:
3
+ metadata.gz: 50f3566cc5d434fa1877142a1ce9e993277f3a0d617d2030be78ae801c96113c
4
+ data.tar.gz: 18949992ca7ee9ced52cf8fc13db55c8689c37f59655f1ae10af4ee88ea52196
5
5
  SHA512:
6
- metadata.gz: 8d2989cd6e3e98aafe5ee7ae8695fa69ad966cc2041f6bba6050f621162ef7c0e3e84726d18288b0ef539ef6d55e56fd8958c04a7eac3784d63b6e1bb7d968f7
7
- data.tar.gz: 495f5fa66411e5e4f32fc2084732efd0ef192223e5e0327db935beded455a967357b38fbbfe5aff446636aa3c6a98500555be5ec0e9f7f7ce88cb93a478d5e09
6
+ metadata.gz: e872ba1fb97cd0ed444735cb5f2d53b21f25c6673b51e31adc630dd5a47d93d0d2a457d0b8190042b5d8daa6999abff29cd066b203f3705c108cdc7446bf8822
7
+ data.tar.gz: e90c0de40e03bcf5937cba724f322f99f66f0e8dd3d9a721aa7e3719008f923402fcba83fb59cccfb0a41f1bbfb5e0e32476e5778a317a0621efa9496041e689
@@ -177,6 +177,8 @@ class Data::Validator
177
177
  fillin << key
178
178
  elsif rule[:optional] then
179
179
  # ok
180
+ elsif @isa then
181
+ missing << key
180
182
  elsif @rule[:allow_extra] then
181
183
  # ok
182
184
  else
@@ -20,4 +20,4 @@
20
20
  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  # SOFTWARE.
23
- Data::Validator::VERSION = "1.1.2"
23
+ Data::Validator::VERSION = "1.1.3"
@@ -0,0 +1,30 @@
1
+ require 'test-unit'
2
+ require 'data/validator'
3
+
4
+ class Test02Validate < Test::Unit::TestCase
5
+ test 'requires with AllowExtra' do
6
+ rule = Data::Validator::Recursive.new(
7
+ 'foo' => String,
8
+ 'bar' => { isa: Integer, default: 1 },
9
+ 'baz' => {
10
+ isa: Hash,
11
+ with: 'AllowExtra',
12
+ rule: {
13
+ 'hoge' => { isa: String }, # requires
14
+ 'fuga' => Integer,
15
+ },
16
+ },
17
+ ).with('AllowExtra')
18
+
19
+ input = {
20
+ 'foo' => 'xxx',
21
+ 'baz' => {
22
+ 'fuga' => 123,
23
+ 'extra_param_in_baz' => 1,
24
+ },
25
+ 'extra_param' => 1,
26
+ }
27
+
28
+ assert_raise_message(/missing/) { rule.validate(input) }
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urabe, Shyouhei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-28 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,6 +127,7 @@ files:
127
127
  - lib/data/validator/recursive.rb
128
128
  - lib/data/validator/version.rb
129
129
  - test/01_orclass.rb
130
+ - test/02_validate_requires_allowextra.rb
130
131
  - test/gfx/000_load.rb
131
132
  - test/gfx/001_basic.rb
132
133
  - test/gfx/002_isa.rb
@@ -158,13 +159,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.4.5.4
162
+ rubygems_version: 3.3.0.dev
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: p5-Data-Validator / p5-Data-Validator-Recursive port
166
166
  test_files:
167
167
  - test/01_orclass.rb
168
+ - test/02_validate_requires_allowextra.rb
168
169
  - test/gfx/000_load.rb
169
170
  - test/gfx/001_basic.rb
170
171
  - test/gfx/002_isa.rb