openc-json_schema 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjczNDczZDkzN2I5NTkyNjc1Mzk1ZGJjNzIyOWMwYzI5NTk1ODA3YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjcxODZkNjdlMTc4YmQ0MGZhNGJlOGUwNTA2ZWYyZDEwZmE3MzRlMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWU4YzY3ZmY5MzlhNzE2MDVlNzVlMmI5MGZmOTY1NWQyYjcxMzkzOWU3N2M5
|
10
|
+
MzBiYmM4NGExYmFkMTIwODZjZGY2NTBmYzk1OGIwYmFkOTExY2Y1ZDZjM2I4
|
11
|
+
MjY0ZjlhNzZjNjVmZjE1NThhOWZmZjNkMDVhNWNiZmZmNWYyYzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmJhNThmYTY5ZDAzZmNlZmMzM2VlOGY0YzNmMGI2YTU5ODc5ZWUzY2M1NDVj
|
14
|
+
OWUwM2I4OGQ0MDFhNjMwOWQ2NTBjZGY3YmRkOGRlZmU5ZDE3MDc1NDIzMzVm
|
15
|
+
OTUxZTAwMDhlNmRlMWM5M2ZkZTZjMjU3OWE2MjQ5OTZkM2VhOTk=
|
data/Gemfile.lock
CHANGED
@@ -9,3 +9,9 @@ date_format_validator = -> value {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
JSON::Validator.register_format_validator('date', date_format_validator)
|
12
|
+
|
13
|
+
non_blank_format_validator = -> value {
|
14
|
+
raise JSON::Schema::CustomFormatError.new('must not be blank') if value.strip == ''
|
15
|
+
}
|
16
|
+
|
17
|
+
JSON::Validator.register_format_validator('non-blank', non_blank_format_validator)
|
@@ -136,6 +136,9 @@ module Openc
|
|
136
136
|
type = :format_mismatch
|
137
137
|
message = "Property not of expected format: #{path} (must be of format yyyy-mm-dd)"
|
138
138
|
extra_params = {:expected_format => 'yyyy-mm-dd'}
|
139
|
+
elsif error[:message].match(/must not be blank/)
|
140
|
+
type = :format_mismatch
|
141
|
+
message = "Property not of expected format: #{path} (must not be blank)"
|
139
142
|
else
|
140
143
|
type = :unknown
|
141
144
|
message = "Error of unknown type: #{path} (#{error[:message]})"
|
@@ -277,7 +277,7 @@ describe Openc::JsonSchema do
|
|
277
277
|
expect([schema, record]).to fail_validation_with(error)
|
278
278
|
end
|
279
279
|
|
280
|
-
specify 'when property of wrong format' do
|
280
|
+
specify 'when date property of wrong format' do
|
281
281
|
schema = {
|
282
282
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
283
283
|
'type' => 'object',
|
@@ -291,7 +291,7 @@ describe Openc::JsonSchema do
|
|
291
291
|
expect([schema, record]).to fail_validation_with(error)
|
292
292
|
end
|
293
293
|
|
294
|
-
specify 'when property
|
294
|
+
specify 'when date property is empty' do
|
295
295
|
schema = {
|
296
296
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
297
297
|
'type' => 'object',
|
@@ -305,6 +305,20 @@ describe Openc::JsonSchema do
|
|
305
305
|
expect([schema, record]).to fail_validation_with(error)
|
306
306
|
end
|
307
307
|
|
308
|
+
specify 'when non-blank property of wrong format' do
|
309
|
+
schema = {
|
310
|
+
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
311
|
+
'type' => 'object',
|
312
|
+
'properties' => {
|
313
|
+
'aaa' => {'type' => 'string', 'format' => 'non-blank'}
|
314
|
+
}
|
315
|
+
}
|
316
|
+
record = {'aaa' => ' '}
|
317
|
+
|
318
|
+
error = 'Property not of expected format: aaa (must not be blank)'
|
319
|
+
expect([schema, record]).to fail_validation_with(error)
|
320
|
+
end
|
321
|
+
|
308
322
|
context 'when schema includes $ref' do
|
309
323
|
specify 'when data is valid' do
|
310
324
|
schema_path = 'spec/schemas/aaa.json'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openc-json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenCorporates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|