nakischema 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 689c8c7026e418ee31898770feab157880a985eb
4
- data.tar.gz: ec2ea8c9c77caf975a1a14e041cafaeab2cb81f9
3
+ metadata.gz: f1ee5445ac066ed5b77d5dd3554d96a4c7723e26
4
+ data.tar.gz: 4302db46b28684a12f8c8b259c8597373355a011
5
5
  SHA512:
6
- metadata.gz: c4dd0ad379925c22804b8d261cf829051b3333123b682bba08b4100fcb7fb6aec81473b12b4611d0d35ce89abfdd645f19affa3f6f1a746cf1e377ebee0ef6bc
7
- data.tar.gz: 40dc899497e377794e6af4fb5c1583de143a32c384bdb4595a94af8a671b2c6ba377a821f019da9737f26bfd8ffe998824c23c92c0fae0263a262ad7d48c91b7
6
+ metadata.gz: 91252167fbe10d1808ea86f108fc37d9ac6be0a36b99cccfab36dc2960ba04b161ac153a66071181cd394dc36ab512c4a5d7363a7e8dd3fe86ba39ea7b52b984
7
+ data.tar.gz: 422749ffe71639df10e08790406a03687d35e056213c1ad977f41b7ceec22ed727e38a28382af7fab75297cec9a808f373d18581a9584ea0e4d43d1111482e15
data/lib/nakischema.rb CHANGED
@@ -6,6 +6,11 @@ module Nakischema
6
6
  end
7
7
  # TODO: maybe move '(at ...)' to the beginning
8
8
  case schema
9
+ when NilClass, TrueClass, FalseClass, String, Symbol ; raise_with_path.call "expected #{schema.inspect} != #{object.inspect}" unless schema == object
10
+ # TODO: maybe deprecate the NilClass, TrueClass, FalseClass since they can be asserted via the next case branch
11
+ when Class ; raise_with_path.call "expected #{schema } != #{object.class }" unless schema === object
12
+ when Regexp ; raise_with_path.call "expected #{schema } != #{object.inspect}" unless schema === object
13
+ when Range ; raise_with_path.call "expected #{schema } != #{object }" unless schema.include? object
9
14
  when Hash
10
15
  raise_with_path.call "expected Hash != #{object.class}" unless object.is_a? Hash unless (schema.keys & %i{ keys each_key each_value }).empty?
11
16
  raise_with_path.call "expected Array != #{object.class}" unless object.is_a? Array unless (schema.keys & %i{ size }).empty?
@@ -51,9 +56,6 @@ module Nakischema
51
56
  raise_with_path.call "unsupported rule #{k.inspect}"
52
57
  end
53
58
  end
54
- when NilClass, TrueClass, FalseClass, String, Symbol ; raise_with_path.call "expected #{schema.inspect} != #{object.inspect}" unless schema == object
55
- when Regexp ; raise_with_path.call "expected #{schema } != #{object.inspect}" unless schema === object
56
- when Range ; raise_with_path.call "expected #{schema } != #{object }" unless schema.include? object
57
59
  when Array
58
60
  if schema.map(&:class) == [Array]
59
61
  raise_with_path.call "expected Array != #{object.class}" unless object.is_a? Array
data/nakischema.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "nakischema"
3
- spec.version = "0.0.3"
3
+ spec.version = "0.1.0"
4
4
  spec.summary = "compact yet powerful arbitrary nested objects validator"
5
5
  spec.description = "The most compact yet powerful arbitrary nested objects validator. Especially handy to validate JSONs."
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nakischema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov aka Nakilon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-09-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The most compact yet powerful arbitrary nested objects validator. Especially
14
14
  handy to validate JSONs.