validatable 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,12 +13,13 @@ module Validatable
13
13
  #
14
14
  # Configuration options:
15
15
  #
16
+ # * after_validate - A block that executes following the run of a validation
17
+ # * group - The group that this validation belongs to. A validation can belong to multiple groups
18
+ # * if - A block that when executed must return true of the validation will not occur
19
+ # * level - The level at which the validation should occur
20
+ # * logic - A block that executes to perform the validation
16
21
  # * message - The message to add to the errors collection when the validation fails
17
22
  # * times - The number of times the validation applies
18
- # * level - The level at which the validation should occur
19
- # * if - A block that when executed must return true of the validation will not occur
20
- # * group - The group that this validation belongs to. A validation can belong to multiple groups
21
- # * logic - A block that executes to perform the validation def validates_each(*args)
22
23
  def validates_each(*args)
23
24
  add_validations(args, ValidatesEach)
24
25
  end
@@ -37,6 +38,7 @@ module Validatable
37
38
  #
38
39
  # Configuration options:
39
40
  #
41
+ # * after_validate - A block that executes following the run of a validation
40
42
  # * message - The message to add to the errors collection when the validation fails
41
43
  # * times - The number of times the validation applies
42
44
  # * level - The level at which the validation should occur
@@ -59,6 +61,7 @@ module Validatable
59
61
  #
60
62
  # Configuration options:
61
63
  #
64
+ # * after_validate - A block that executes following the run of a validation
62
65
  # * message - The message to add to the errors collection when the validation fails
63
66
  # * times - The number of times the validation applies
64
67
  # * level - The level at which the validation should occur
@@ -83,6 +86,7 @@ module Validatable
83
86
  #
84
87
  # Configuration options:
85
88
  #
89
+ # * after_validate - A block that executes following the run of a validation
86
90
  # * message - The message to add to the errors collection when the validation fails
87
91
  # * times - The number of times the validation applies
88
92
  # * level - The level at which the validation should occur
@@ -105,6 +109,7 @@ module Validatable
105
109
  #
106
110
  # Configuration options:
107
111
  #
112
+ # * after_validate - A block that executes following the run of a validation
108
113
  # * message - The message to add to the errors collection when the validation fails
109
114
  # * times - The number of times the validation applies
110
115
  # * level - The level at which the validation should occur
@@ -131,6 +136,7 @@ module Validatable
131
136
  #
132
137
  # Configuration options:
133
138
  #
139
+ # * after_validate - A block that executes following the run of a validation
134
140
  # * case_sensitive - Whether or not to apply case-sensitivity on the comparison. Defaults to true.
135
141
  # * message - The message to add to the errors collection when the validation fails
136
142
  # * times - The number of times the validation applies
@@ -154,6 +160,7 @@ module Validatable
154
160
  #
155
161
  # Configuration options:
156
162
  #
163
+ # * after_validate - A block that executes following the run of a validation
157
164
  # * message - The message to add to the errors collection when the validation fails
158
165
  # * times - The number of times the validation applies
159
166
  # * level - The level at which the validation should occur
@@ -176,6 +183,7 @@ module Validatable
176
183
  #
177
184
  # Configuration options:
178
185
  #
186
+ # * after_validate - A block that executes following the run of a validation
179
187
  # * message - The message to add to the errors collection when the validation fails
180
188
  # * times - The number of times the validation applies
181
189
  # * level - The level at which the validation should occur
@@ -41,7 +41,7 @@ module Validatable
41
41
  include Understandable
42
42
  include Requireable
43
43
 
44
- option :message, :if, :times, :level, :groups, :key
44
+ option :message, :if, :times, :level, :groups, :key, :after_validate
45
45
  default :level => 1, :groups => []
46
46
  attr_accessor :attribute
47
47
 
@@ -82,6 +82,7 @@ module Validatable
82
82
  self.class.all_after_validations.each do |block|
83
83
  block.call result, instance, attribute
84
84
  end
85
+ self.after_validate.call result, instance, attribute unless self.after_validate.nil?
85
86
  end
86
87
  end
87
88
  end
@@ -29,7 +29,7 @@ Gem::manage_gems
29
29
  specification = Gem::Specification.new do |s|
30
30
  s.name = "validatable"
31
31
  s.summary = "Validatable is a library for adding validations."
32
- s.version = "1.6.2"
32
+ s.version = "1.6.3"
33
33
  s.author = 'Jay Fields'
34
34
  s.description = "Validatable is a library for adding validations."
35
35
  s.email = 'validatable-developer@rubyforge.org'
@@ -2,6 +2,18 @@ require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
3
  functional_tests do
4
4
 
5
+ expect :is_set do
6
+ klass = Class.new do
7
+ include Validatable
8
+ attr_accessor :name, :result
9
+ validates_presence_of :name, :after_validate => lambda { |result, instance, attribute| instance.result = :is_set }
10
+ end
11
+
12
+ instance = klass.new
13
+ instance.valid?
14
+ instance.result
15
+ end
16
+
5
17
  expect false do
6
18
  klass = Class.new do
7
19
  include Validatable
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: validatable
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.6.2
6
+ version: 1.6.3
7
7
  date: 2007-08-15 00:00:00 -04:00
8
8
  summary: Validatable is a library for adding validations.
9
9
  require_paths: