conditional_validation 0.0.3 → 0.0.4

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: 4f8439c1243d6b4e770578bbe617ae84198b357e
4
- data.tar.gz: 354132d0055c66be64b37e1b9795c45006341951
3
+ metadata.gz: 90cffc4ad349929eec7e85fe75148d41c88d1ca1
4
+ data.tar.gz: 1ab36808cdd42d52e10322d6d4bc30756d730556
5
5
  SHA512:
6
- metadata.gz: f7472d107e930e460cbf41cc915b1e29ff783c889538872cd29b38c21dfbd6a3ceb8a525be0192eb5fee1dc78a4346fcc06295c68832dab3cd9508729a4ccb6f
7
- data.tar.gz: aee3f61319d87dc3b3db636d95da59f0a036673152dce706dff52b82031438631966a4ee3a952c6010533542c4c08f666226ab8f7d160beec00700123850716e
6
+ metadata.gz: e94799edf5f451c998a291478ba7e407f285aaf4ad256e8c1b82ff19943c5807465f21fa34a4cb3187e06a7b6793904eae8b5a529a5ae5add6c840a4ee44d9e2
7
+ data.tar.gz: 10167ba772717e646d678c8294dc3e0d3776b32d769af5408170c81363fdfc275036b5cb6ccddea6c2c48f7d030ed5cc18fc407f5f5a987c98265114c6d01c76
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Conditional Validation
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/conditional_validation.png)](http://badge.fury.io/rb/conditional_validation)
4
+
5
+ Conditional Validation allows controllers to communicate with models about
6
+ whether or not certain validations should be run. This is great for multi-page
7
+ wizards and context-dependent validations.
8
+
9
+ ## Compatibility
10
+
11
+ Tested with:
12
+
13
+ * Ruby: MRI 2.0.0
14
+ * Rails: 4.0.1
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem "conditional_validation"
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```ruby
27
+ bundle
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ First, define a validation accessor:
33
+
34
+ ```ruby
35
+ # app/models/some_model.rb
36
+ class SomeModel
37
+ validation_accessor :some_grouping_name
38
+ end
39
+ ```
40
+
41
+ Then, this model will receive the following methods for conditional validation:
42
+
43
+ ```ruby
44
+ enable_some_grouping_name_validation # Enables conditional validation
45
+ disable_some_grouping_name_validation # Disables conditional validation
46
+ validate_on_some_grouping_name? # Check if conditional validation is enabled
47
+ ```
48
+
49
+ <b>A "Real World" Example</b>
50
+
51
+ ```ruby
52
+ # app/models/user.rb
53
+ User < ActiveRecord::Base
54
+ validation_accessor :address_attributes # Initialize conditional validation on address attributes
55
+
56
+ with_options if: :validate_on_address_attributes? do |obj|
57
+ obj.validates :street, presence: true
58
+ obj.validates :city, presence: true
59
+ # ...
60
+ end
61
+ end
62
+
63
+ # app/controllers/user_controller.rb
64
+ def update
65
+ current_user.enable_address_attributes_validation # Enable conditional validation on address attributes
66
+ if current_user.save
67
+ current_user.disable_address_attributes_validation # Not necessarily needed, but disables conditional validation on address attributes
68
+ # ...
69
+ end
70
+ end
71
+ ```
72
+
73
+ <b>Method Chaining</b>
74
+
75
+ The enable and disable methods allow for method chaining so that multiple
76
+ validation accessors may be enabled/disabled at once:
77
+
78
+ ```ruby
79
+ if current_user.enable_address_attributes_validation.enable_some_other_validation.save
80
+ # ...
81
+ end
82
+ ```
83
+
84
+ ## Author
85
+
86
+ - Paul Dobbins
@@ -1,3 +1,3 @@
1
1
  module ConditionalValidation
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conditional_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dobbins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +93,7 @@ files:
93
93
  - lib/conditional_validation.rb
94
94
  - MIT-LICENSE
95
95
  - Rakefile
96
+ - README.md
96
97
  - test/conditional_validation_test.rb
97
98
  - test/dummy/app/assets/javascripts/application.js
98
99
  - test/dummy/app/assets/stylesheets/application.css
@@ -136,7 +137,8 @@ files:
136
137
  - test/dummy/test/models/user_test.rb
137
138
  - test/test_helper.rb
138
139
  homepage: https://github.com/pdobb/conditional_validation
139
- licenses: []
140
+ licenses:
141
+ - MIT
140
142
  metadata: {}
141
143
  post_install_message:
142
144
  rdoc_options: []
@@ -154,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  version: '0'
155
157
  requirements: []
156
158
  rubyforge_project:
157
- rubygems_version: 2.1.10
159
+ rubygems_version: 2.1.11
158
160
  signing_key:
159
161
  specification_version: 4
160
162
  summary: Add conditional validation methods to a model.