compel 0.5.0 → 0.5.1

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
  SHA1:
3
- metadata.gz: 760b8bea600ef35e2feaf4f884ce9993e60308f2
4
- data.tar.gz: 2d6c7964a591146d16920535d751c5e4bc786d57
3
+ metadata.gz: 6798eb1df155bad2dda43b8bd27c4f8228864d64
4
+ data.tar.gz: 152a7785537b339248c10a9024d8bdc7becb290a
5
5
  SHA512:
6
- metadata.gz: ac24d0904ce924b9c34a44faaaa5fc138840412ad57db195e743d7ac0e40251adc0e2dc1cf37bee934acb9a9c777006abbd920743f4a6d881cc360c4bc2b81c6
7
- data.tar.gz: 727af6ca9af8da14f937aacf58f3a4b52224c38a7db63cabd4ad8d1cef1d9be8609b8fae29a5e6995d3e00e36cfc8c875465c7732fd6b001a4bc480a1ebb07f9
6
+ metadata.gz: 8ee5e8d79756afec693c9c29726896a546b972663fa2731cde521c3c22200d0367dc60d673f9f529fad8464c9df72d14671cf6e463e3955195c92f97a75068a4
7
+ data.tar.gz: 2505ef24f62871a1e5e038f091b43215fece8db5241bcc3790c054b73de1c2b3cf34e95c5849774ff1dc387114c32a15c43ecbf2a2e73c1b3f43be0b81c9be5a
data/README.md CHANGED
@@ -295,7 +295,7 @@ end
295
295
 
296
296
  Add this line to your application's Gemfile:
297
297
 
298
- gem 'compel', '~> 0.4.3'
298
+ gem 'compel', '~> 0.5.0'
299
299
 
300
300
  And then execute:
301
301
 
@@ -12,7 +12,13 @@ module Compel
12
12
  private
13
13
 
14
14
  def valid?
15
- !value.nil? && "#{value}".length <= option_value
15
+ unless value.nil?
16
+ _value = value.is_a?(Array) || value.is_a?(Hash) ? value.dup : "#{value}"
17
+
18
+ return _value.length <= option_value
19
+ end
20
+
21
+ true
16
22
  end
17
23
 
18
24
  end
@@ -12,7 +12,13 @@ module Compel
12
12
  private
13
13
 
14
14
  def valid?
15
- !value.nil? && option_value <= "#{value}".length
15
+ unless value.nil?
16
+ _value = value.is_a?(Array) || value.is_a?(Hash) ? value.dup : "#{value}"
17
+
18
+ return option_value <= _value.length
19
+ end
20
+
21
+ true
16
22
  end
17
23
 
18
24
  end
@@ -1,3 +1,3 @@
1
1
  module Compel
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -1162,6 +1162,32 @@ describe Compel::Builder do
1162
1162
 
1163
1163
  end
1164
1164
 
1165
+ context '#min_length' do
1166
+
1167
+ it 'should validate empty array without errors' do
1168
+ result = Compel.array.min_length(1).validate([])
1169
+
1170
+ expect(result.valid?).to be false
1171
+
1172
+ expect(result.errors[:base]).to include \
1173
+ 'cannot have length less than 1'
1174
+ end
1175
+
1176
+ end
1177
+
1178
+ context '#max_length' do
1179
+
1180
+ it 'should validate empty array without errors' do
1181
+ result = Compel.array.max_length(2).validate([1, 2, 3])
1182
+
1183
+ expect(result.valid?).to be false
1184
+
1185
+ expect(result.errors[:base]).to include \
1186
+ 'cannot have length greater than 2'
1187
+ end
1188
+
1189
+ end
1190
+
1165
1191
  end
1166
1192
 
1167
1193
  context 'DateTime' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joaquim Adráz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.5.1
152
+ rubygems_version: 2.6.3
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: Ruby Object Coercion and Validation