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
- Yjc2NjM2ZGVkOGMwZmEyYzBiZDRjN2U2ZDIxNmQ0OGJjYTI3NGM1Ng==
4
+ YjczNDczZDkzN2I5NTkyNjc1Mzk1ZGJjNzIyOWMwYzI5NTk1ODA3YQ==
5
5
  data.tar.gz: !binary |-
6
- ODA1YjNmZTgwNWUwNTg1YzE2OWVmNmE3ZTA5ZWZkZGJiZjczMzU1Yw==
6
+ ZjcxODZkNjdlMTc4YmQ0MGZhNGJlOGUwNTA2ZWYyZDEwZmE3MzRlMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MThmY2IyMGNlODZkODk0NWQzNzM2ZTNjMDkyY2M2MjYzYWZiMmM1OTM5MWY1
10
- ZjhmYjY2YjcyODlkZTFlMTZmNGE3MTc4MzBkNWJhMTJlN2Q5NzNmMjZlOWFi
11
- MTcxNzJlYTQyZGViNjhhZDY5ZDBkYmFmODc4YTgwZTViMTZmOWI=
9
+ YWU4YzY3ZmY5MzlhNzE2MDVlNzVlMmI5MGZmOTY1NWQyYjcxMzkzOWU3N2M5
10
+ MzBiYmM4NGExYmFkMTIwODZjZGY2NTBmYzk1OGIwYmFkOTExY2Y1ZDZjM2I4
11
+ MjY0ZjlhNzZjNjVmZjE1NThhOWZmZjNkMDVhNWNiZmZmNWYyYzg=
12
12
  data.tar.gz: !binary |-
13
- ODQyZjE2OTFjN2E3NjRkMTM5OWUxMzQwZWJiYjJjMTlmYjZlNzY2MzM4OTY2
14
- ZDU5ODcwZWE0ZTVhZDhiY2I3MjdiYzYxYzc2YjhjMmRjMjdiMmE4ZTJjMDNk
15
- MWM2MzVkYzNiNzVlNjI3OThiOGI3ODkzN2QyNWE1ZjY3MDZlNDE=
13
+ YmJhNThmYTY5ZDAzZmNlZmMzM2VlOGY0YzNmMGI2YTU5ODc5ZWUzY2M1NDVj
14
+ OWUwM2I4OGQ0MDFhNjMwOWQ2NTBjZGY3YmRkOGRlZmU5ZDE3MDc1NDIzMzVm
15
+ OTUxZTAwMDhlNmRlMWM5M2ZkZTZjMjU3OWE2MjQ5OTZkM2VhOTk=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openc-json_schema (0.0.9)
4
+ openc-json_schema (0.0.10)
5
5
  json-schema-openc-fork (= 0.0.1)
6
6
 
7
7
  GEM
@@ -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]})"
@@ -1,5 +1,5 @@
1
1
  module Openc
2
2
  module JsonSchema
3
- VERSION = '0.0.9'
3
+ VERSION = '0.0.10'
4
4
  end
5
5
  end
@@ -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 with format is empty' do
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.9
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-20 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler