compel 0.5.0 → 0.5.1
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 +4 -4
- data/README.md +1 -1
- data/lib/compel/validation/conditions/max_length.rb +7 -1
- data/lib/compel/validation/conditions/min_length.rb +7 -1
- data/lib/compel/version.rb +1 -1
- data/spec/compel/builder_spec.rb +26 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6798eb1df155bad2dda43b8bd27c4f8228864d64
|
4
|
+
data.tar.gz: 152a7785537b339248c10a9024d8bdc7becb290a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee5e8d79756afec693c9c29726896a546b972663fa2731cde521c3c22200d0367dc60d673f9f529fad8464c9df72d14671cf6e463e3955195c92f97a75068a4
|
7
|
+
data.tar.gz: 2505ef24f62871a1e5e038f091b43215fece8db5241bcc3790c054b73de1c2b3cf34e95c5849774ff1dc387114c32a15c43ecbf2a2e73c1b3f43be0b81c9be5a
|
data/README.md
CHANGED
@@ -12,7 +12,13 @@ module Compel
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def valid?
|
15
|
-
|
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
|
-
|
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
|
data/lib/compel/version.rb
CHANGED
data/spec/compel/builder_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
152
|
+
rubygems_version: 2.6.3
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Ruby Object Coercion and Validation
|