composed_validations 0.0.4 → 0.0.5

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: 8d89729666fefa1d939fab5404db545fb38d54c4
4
- data.tar.gz: 3840e021b0bca686a7f60671d4e011a6cc945992
3
+ metadata.gz: 22ebe8805f62d416cfaaff61e6341ff5a3ea8b94
4
+ data.tar.gz: 01ae1de017cb090ce2d8a3956a3b23c8f2f7a4f2
5
5
  SHA512:
6
- metadata.gz: 20aab6508544be7422acec7289458517b69cdccb15327f1f19b6bbe7f4d9ff88c2eccd9549871fabb43f0eeec7f4a6ecd1c244b14b8b6e4887eea952735aec86
7
- data.tar.gz: 50be9b4b2d8caa5384de8c30a11b8e472a7f3cb350374bf5e62b09c6dcc080ae003a8920acebcd207359e304d36b7b389fc6e0f97c5d4aef7d2cf01aa3536e3e
6
+ metadata.gz: 6a5f6eef97ecb69089887584676ca5750bf4e389f6542e793234fe9bfd90bffffa62e5fcdd17389e525faefeeb0ae9de380675a846dceab2012b667ac0412f0f
7
+ data.tar.gz: 53510e6d473be82537cdc9e86ac48256fe8433c5d7dc1567541b4485c2423f2106e2f8d2f558a89e93060b7ddb82f97da18c3adde0ab728c0aa5d5a017cb5130
data/README.md CHANGED
@@ -42,12 +42,12 @@ end
42
42
  ### Validators
43
43
 
44
44
  Validators are objects which takes the result of using a property accessor and
45
- says whether or not it's valid. It responds to `valid?(value)` and `message`(the
45
+ says whether or not it's valid. It responds to `valid_value?(value)` and `message`(the
46
46
  message which gets added to errors if this is not valid.)
47
47
 
48
48
  ```ruby
49
49
  class StringIsBob
50
- def valid?(value)
50
+ def valid_value?(value)
51
51
  value.to_s == "Bob"
52
52
  end
53
53
 
@@ -5,9 +5,9 @@ module ComposedValidations
5
5
  @validators = Array(validators)
6
6
  end
7
7
 
8
- def valid?(record)
8
+ def valid_value?(record)
9
9
  validators.all? do |validator|
10
- validator.valid?(record)
10
+ validator.valid_value?(record)
11
11
  end
12
12
  end
13
13
 
@@ -2,9 +2,9 @@ module ComposedValidations
2
2
  class OrValidator
3
3
  pattr_initialize :validators
4
4
 
5
- def valid?(record)
5
+ def valid_value?(record)
6
6
  validators.any? do |validator|
7
- validator.valid?(record)
7
+ validator.valid_value?(record)
8
8
  end
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module ComposedValidations
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -13,7 +13,7 @@ module ComposedValidations
13
13
 
14
14
  def valid?(*args)
15
15
  __getobj__.valid?(*args)
16
- unless validator.valid?(result)
16
+ unless validator.valid_value?(result)
17
17
  errors.add(property.validated_property, validator.message)
18
18
  end
19
19
  errors.blank?
@@ -8,7 +8,7 @@ RSpec.describe ComposedValidations::AndValidator do
8
8
 
9
9
  describe "#valid?" do
10
10
  let(:value) { double("value") }
11
- let(:result) { subject.valid?(value) }
11
+ let(:result) { subject.valid_value?(value) }
12
12
  context "when both validators are valid" do
13
13
  it "should return true" do
14
14
  expect(result).to eq true
@@ -49,7 +49,7 @@ RSpec.describe ComposedValidations::AndValidator do
49
49
 
50
50
  def mock_validator(valid:)
51
51
  i = double("validator")
52
- allow(i).to receive(:valid?).and_return(valid)
52
+ allow(i).to receive(:valid_value?).and_return(valid)
53
53
  allow(i).to receive(:message).and_return("message")
54
54
  i
55
55
  end
@@ -8,7 +8,7 @@ RSpec.describe ComposedValidations::OrValidator do
8
8
 
9
9
  describe "#valid?" do
10
10
  let(:value) { double("value") }
11
- let(:result) { subject.valid?(value) }
11
+ let(:result) { subject.valid_value?(value) }
12
12
  context "when both validators are valid" do
13
13
  it "should return true" do
14
14
  expect(result).to eq true
@@ -36,7 +36,7 @@ RSpec.describe ComposedValidations::OrValidator do
36
36
 
37
37
  def mock_validator(valid:)
38
38
  i = double("validator")
39
- allow(i).to receive(:valid?).and_return(valid)
39
+ allow(i).to receive(:valid_value?).and_return(valid)
40
40
  allow(i).to receive(:message).and_return("message")
41
41
  i
42
42
  end
@@ -28,7 +28,7 @@ RSpec.describe ComposedValidations::WithValidatedProperty do
28
28
  let(:valid) { true }
29
29
  let(:valid_result) { subject.valid? }
30
30
  before do
31
- allow(validator).to receive(:valid?).with(result).and_return(valid)
31
+ allow(validator).to receive(:valid_value?).with(result).and_return(valid)
32
32
  valid_result
33
33
  end
34
34
  it "should call asset.valid?" do
@@ -8,7 +8,7 @@ RSpec.describe "Or Validations Spec" do
8
8
  attr_accessor :title, :description
9
9
  end
10
10
  class ValueIsFrank
11
- def valid?(value)
11
+ def valid_value?(value)
12
12
  value.to_s == "Frank"
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ RSpec.describe "Or Validations Spec" do
17
17
  end
18
18
  end
19
19
  class LengthIsFour
20
- def valid?(value)
20
+ def valid_value?(value)
21
21
  value.to_s.length == 4
22
22
  end
23
23
 
@@ -8,7 +8,7 @@ RSpec.describe "Validations Integration Spec" do
8
8
  attr_accessor :title, :description
9
9
  end
10
10
  class ValueIsFrank
11
- def valid?(value)
11
+ def valid_value?(value)
12
12
  value.to_s == "Frank"
13
13
  end
14
14
 
@@ -17,7 +17,7 @@ RSpec.describe "Validations Integration Spec" do
17
17
  end
18
18
  end
19
19
  class LengthIsFive
20
- def valid?(value)
20
+ def valid_value?(value)
21
21
  value.to_s.length == 5
22
22
  end
23
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composed_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trey Terrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attr_extras