sexy_validations 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/lib/sexy_validations/validators/count.rb +20 -7
- data/lib/sexy_validations.rb +3 -1
- data/sexy_validations.gemspec +2 -2
- metadata +3 -3
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
@@ -10,15 +10,28 @@ module SexyValidations
|
|
10
10
|
:within => options,
|
11
11
|
}
|
12
12
|
end
|
13
|
+
|
14
|
+
case options[:within]
|
15
|
+
when Fixnum, Integer, Bignum
|
16
|
+
unless value.count == options[:within]
|
17
|
+
record.errors.add(attribute, "ungültige Anzahl Selektionen")
|
18
|
+
end
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
when Array
|
21
|
+
unless options[:within].include?(value.count)
|
22
|
+
record.errors.add(attribute, "ungültige Anzahl Selektionen")
|
23
|
+
end
|
24
|
+
|
25
|
+
when Range
|
26
|
+
min = options[:within].min
|
27
|
+
if value.count < min
|
28
|
+
record.errors.add(attribute, "zu wenig Selektionen (mindestes #{min})")
|
29
|
+
end
|
18
30
|
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
max = options[:within].max
|
32
|
+
if value.count > max
|
33
|
+
record.errors.add(attribute, "zu viele Selektionen (maximal #{max})")
|
34
|
+
end
|
22
35
|
end
|
23
36
|
end
|
24
37
|
end
|
data/lib/sexy_validations.rb
CHANGED
@@ -3,7 +3,9 @@ require 'sexy_validations/errors'
|
|
3
3
|
module SexyValidations
|
4
4
|
def self.load_validator(name)
|
5
5
|
require "sexy_validations/validators/#{name}"
|
6
|
-
"SexyValidations::Validators::#{name.to_s.
|
6
|
+
"SexyValidations::Validators::#{name.to_s.camelize}".constantize
|
7
|
+
rescue LoadError
|
8
|
+
"::#{name.to_s.camelize}Validator".constantize
|
7
9
|
end
|
8
10
|
|
9
11
|
def self.included(klass)
|
data/sexy_validations.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sexy_validations}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Corin Langosch"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-06}
|
13
13
|
s.description = %q{Module which provides sexy validations for models.}
|
14
14
|
s.email = %q{info@netskin.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 3
|
9
|
+
version: 0.4.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Corin Langosch
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-06 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|