validatable2 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
data/lib/validatable/macros.rb
CHANGED
@@ -69,7 +69,7 @@ module Validatable
|
|
69
69
|
# * minimum - The minimum size of the attribute
|
70
70
|
# * maximum - The maximum size of the attribute
|
71
71
|
# * is - The size the attribute must be
|
72
|
-
# *
|
72
|
+
# * in - A range that the size of the attribute must fall in
|
73
73
|
# * group - The group that this validation belongs to. A validation can belong to multiple groups
|
74
74
|
def validates_length_of(*args)
|
75
75
|
add_validations(args, ValidatesLengthOf)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Validatable
|
2
2
|
class ValidatesExclusionOf < ValidationBase #:nodoc:
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :in
|
4
4
|
|
5
5
|
def valid?(instance)
|
6
6
|
value = instance.send(attribute)
|
7
7
|
return true if allow_nil && value.nil?
|
8
8
|
return true if allow_blank && (!value or (value.respond_to?(:empty?) and value.empty?))
|
9
9
|
|
10
|
-
!
|
10
|
+
!self.in.include?(value)
|
11
11
|
end
|
12
12
|
|
13
13
|
def message(instance)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Validatable
|
2
2
|
class ValidatesInclusionOf < ValidationBase
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :in
|
4
4
|
|
5
5
|
def valid?(instance)
|
6
6
|
value = instance.send(attribute)
|
7
7
|
return true if allow_nil && value.nil?
|
8
8
|
return true if allow_blank && (!value or (value.respond_to?(:empty?) and value.empty?))
|
9
9
|
|
10
|
-
|
10
|
+
self. in.include?(value)
|
11
11
|
end
|
12
12
|
|
13
13
|
def message(instance)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Validatable
|
2
2
|
class ValidatesLengthOf < ValidationBase #:nodoc:
|
3
|
-
attr_accessor :minimum, :maximum, :is, :
|
3
|
+
attr_accessor :minimum, :maximum, :is, :in
|
4
4
|
|
5
5
|
def message(instance)
|
6
6
|
super || "is invalid"
|
@@ -23,7 +23,7 @@ module Validatable
|
|
23
23
|
valid &&= value.length <= maximum unless maximum.nil?
|
24
24
|
valid &&= value.length >= minimum unless minimum.nil?
|
25
25
|
valid &&= value.length == is unless is.nil?
|
26
|
-
valid &&=
|
26
|
+
valid &&= self.in.include?(value.length) unless self.in.nil?
|
27
27
|
valid
|
28
28
|
end
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validatable2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-31 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|