jsonapi-validator 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonapi/validator.rb +2 -2
- data/lib/tasks/jsonapi-validator.rb +1 -1
- data/test/test_validator.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1516bff498b1fe5a5f1494037b0cc76917f69822
|
4
|
+
data.tar.gz: 3bb66beda771c5f5ae6def35b1feba3ed2b19320
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ce72fe2be9ea6a7f546a1337625ad43b3e312baf1fd61bbf4e5ee8acdbf0925af9ee5d77693af61ad02658a183111695526d83d3e5fbfe0ef44b97652fa469
|
7
|
+
data.tar.gz: 5123aac1323f9e27e64c73e4c12aa1ef33382c146613070e0de6af7553e2f94b37c5bfc1551d6b81b4a29a53a51d1d456907a74c7e170e28b85167a922b80f93
|
data/lib/jsonapi/validator.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module JsonApi
|
2
2
|
class Validator
|
3
3
|
|
4
|
-
def self.
|
4
|
+
def self.file(file)
|
5
5
|
object = nil
|
6
6
|
File.open(file) do |f|
|
7
7
|
object = JSON.parse(f.read)
|
@@ -9,7 +9,7 @@ module JsonApi
|
|
9
9
|
return json(object)
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
12
|
+
def self.object(object)
|
13
13
|
errors = JSON::Validator.fully_validate(STANDARD_SCHEMA,object)
|
14
14
|
return errors
|
15
15
|
end
|
@@ -7,7 +7,7 @@ namespace "jsonapi" do
|
|
7
7
|
json_spec_files = Dir["#{Rails.root}/spec/apis/**/*.json"]
|
8
8
|
json_spec_files.each do |spec|
|
9
9
|
print "\n\nValidating file '#{spec}': "
|
10
|
-
result = JsonApi::Validator.
|
10
|
+
result = JsonApi::Validator.file(spec)
|
11
11
|
if result.nil? or result.empty?
|
12
12
|
puts " PASSED\n"
|
13
13
|
else
|
data/test/test_validator.rb
CHANGED
@@ -12,10 +12,10 @@ class TestSchema < Minitest::Test
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_invalid_json_object
|
15
|
-
assert_equal JsonApi::Validator.
|
15
|
+
assert_equal JsonApi::Validator.object(@invalid_object)[0].size > 0 ,true
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_valid_json_object
|
19
|
-
assert_equal JsonApi::Validator.
|
19
|
+
assert_equal JsonApi::Validator.object(@valid_object),[]
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karthik selvakumar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|