durran-validatable 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/macros.rb +54 -0
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/macros.rb
CHANGED
@@ -217,6 +217,60 @@ module Validatable
|
|
217
217
|
add_validations(args, ValidatesAssociated)
|
218
218
|
end
|
219
219
|
|
220
|
+
# call-seq: validates_uniqueness_of(*args)
|
221
|
+
#
|
222
|
+
# Checks that the field is unique against existing documents in the database.
|
223
|
+
#
|
224
|
+
# class Person
|
225
|
+
# include Validatable
|
226
|
+
# attr_accessor :name
|
227
|
+
# validates_uniqueness_of :name
|
228
|
+
# end
|
229
|
+
#
|
230
|
+
# Configuration options:
|
231
|
+
#
|
232
|
+
# * message - The message to add to the errors collection when the validation fails
|
233
|
+
# * if - A block that when executed must return true of the validation will not occur
|
234
|
+
def validates_uniqueness_of(*args)
|
235
|
+
add_validations(args, ValidatesAssociated)
|
236
|
+
end
|
237
|
+
|
238
|
+
# call-seq: validates_inclusion_of(*args)
|
239
|
+
#
|
240
|
+
# Checks that the field is included in the supplied list.
|
241
|
+
#
|
242
|
+
# class Person
|
243
|
+
# include Validatable
|
244
|
+
# attr_accessor :name
|
245
|
+
# validates_inclusion_of :name, :within => ["value"]
|
246
|
+
# end
|
247
|
+
#
|
248
|
+
# Configuration options:
|
249
|
+
#
|
250
|
+
# * message - The message to add to the errors collection when the validation fails
|
251
|
+
# * if - A block that when executed must return true of the validation will not occur
|
252
|
+
def validates_inclusion_of(*args)
|
253
|
+
add_validations(args, ValidatesAssociated)
|
254
|
+
end
|
255
|
+
|
256
|
+
# call-seq: validates_exclusion_of(*args)
|
257
|
+
#
|
258
|
+
# Checks that the field is excluded from the supplied list.
|
259
|
+
#
|
260
|
+
# class Person
|
261
|
+
# include Validatable
|
262
|
+
# attr_accessor :name
|
263
|
+
# validates_exclusion_of :name, :within => ["value"]
|
264
|
+
# end
|
265
|
+
#
|
266
|
+
# Configuration options:
|
267
|
+
#
|
268
|
+
# * message - The message to add to the errors collection when the validation fails
|
269
|
+
# * if - A block that when executed must return true of the validation will not occur
|
270
|
+
def validates_exclusion_of(*args)
|
271
|
+
add_validations(args, ValidatesAssociated)
|
272
|
+
end
|
273
|
+
|
220
274
|
# call-seq: include_validations_from(attribute)
|
221
275
|
#
|
222
276
|
# Includes all the validations that are defined on the attribute.
|