type_validator 0.10.0 → 0.11.0

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
2
  SHA256:
3
- metadata.gz: c6d336fb78cd054bc714f18871e7fdf708526d29beb9c7d19ec6156f20e627e7
4
- data.tar.gz: 2ae7196178b31af7ee65bdf7c545869a84c2895a6ca6e7064d486b84fd5817fb
3
+ metadata.gz: 74eb421ea1f47501223d2373ffc493ada6b69a2707b5a958c5570dc6d554cb91
4
+ data.tar.gz: a1462cca7867b4110a34628c64a758ec6fc9966a7ffe81b84434cfe6a2134e53
5
5
  SHA512:
6
- metadata.gz: e867c62076ccf8355855e5b4e92753c6f7cc2121de1eb66a2c2474fcd650272072b1429c37428336efe0c579c35ce302c9224a8fec302bf763de4c1e14c3fdc2
7
- data.tar.gz: 396af9fbb4eef0a2a2d0c51a43b23c6eedfe86cdf2a9ccc287d53e93ed3cedae51a0dee3711f5e6d55738cab7d26155b22bdee4938824caacba8a24e9dc69d0b
6
+ metadata.gz: 5d11e5db37ba9ccdd7619ee093e3f973fb93ad8bfbddfbc53304608b3ec09efc3415b658b69cb8dfb49f9b6a328e2e9cd1f5f45250284ec7541c4b2eae73aa64
7
+ data.tar.gz: c67081c3c93240f2f49c4c74736405ffc364e0f069adaa1694ca2a6125110f94aa78c905d73108fefb9717a7e20ba35311a2c833084c1f091f98f6ffa69e03d9
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.6.3
data/README.md CHANGED
@@ -5,6 +5,9 @@
5
5
 
6
6
  Adds type validation for classes with [`ActiveModel::Validations >= 3.2`](https://api.rubyonrails.org/classes/ActiveModel/Validations.html).
7
7
 
8
+ ## Required Ruby version
9
+ > \>= 2.2.0
10
+
8
11
  ## Installation
9
12
 
10
13
  Add this line to your application's Gemfile:
@@ -57,12 +60,16 @@ validates :status, type: { kind_of: [String, Symbol]}
57
60
  validates :handler, type: { respond_to: :call }
58
61
  ```
59
62
 
63
+ **Class == Class || Class < Class**
64
+
60
65
  ```ruby
61
66
  # Verifies if the attribute value is the class or a subclass.
62
67
 
63
68
  validates :handler, type: { klass: Handler }
64
69
  ```
65
70
 
71
+ **Array.new.all? { |item| item.is_a?(Class) }**
72
+
66
73
  ```ruby
67
74
  validates :account_types, type: { array_of: String }
68
75
 
@@ -72,6 +79,8 @@ validates :account_types, type: { array_of: String }
72
79
  validates :account_types, type: { array_of: [String, Symbol] }
73
80
  ```
74
81
 
82
+ **Array.new.all? { |item| expected_values.include?(item) }**
83
+
75
84
  ```ruby
76
85
  # Verifies if the attribute value
77
86
  # is an array with some or all the expected values.
@@ -79,7 +88,8 @@ validates :account_types, type: { array_of: [String, Symbol] }
79
88
  validates :account_types, type: { array_with: ['foo', 'bar'] }
80
89
  ```
81
90
 
82
- **All the validations above accept:**
91
+ ### All the validations above accept:
92
+
83
93
  - `allow_nil` option. e.g:. e.g:
84
94
  ```ruby
85
95
  validates :name, type: { is_a: String }, allow_nil: true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TypeValidator
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -52,15 +52,6 @@ class TypeValidator < ActiveModel::EachValidator
52
52
  "must be the or a subclass of `#{klass.name}`"
53
53
  end
54
54
 
55
- def validate_klass(value, klass)
56
- require_a_class(value)
57
- require_a_class(klass)
58
-
59
- return if value == klass || value < klass
60
-
61
- "must be the or a subclass of `#{klass.name}`"
62
- end
63
-
64
55
  def require_a_class(arg)
65
56
  raise ArgumentError, "#{arg} must be a class" unless arg.is_a?(Class)
66
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".coveralls.yml"
77
77
  - ".gitignore"
78
+ - ".tool-versions"
78
79
  - ".travis.sh"
79
80
  - ".travis.yml"
80
81
  - CODE_OF_CONDUCT.md