dm-validations 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/dm-validations.rb +1 -1
- data/lib/dm-validations/contextual_validators.rb +2 -3
- data/lib/dm-validations/uniqueness_validator.rb +1 -1
- data/lib/dm-validations/version.rb +1 -1
- data/spec/integration/auto_validate_spec.rb +3 -3
- data/spec/integration/primitive_validator_spec.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/lib/dm-validations.rb
CHANGED
@@ -17,15 +17,14 @@ module DataMapper
|
|
17
17
|
#
|
18
18
|
# @return <Hash> a hash of validators <GenericValidator>
|
19
19
|
def contexts
|
20
|
-
@contexts ||=
|
20
|
+
@contexts ||= {}
|
21
21
|
end
|
22
22
|
|
23
23
|
# Return an array of validators for a named context
|
24
24
|
#
|
25
25
|
# @return <Array> An array of validators
|
26
26
|
def context(name)
|
27
|
-
contexts[name]
|
28
|
-
contexts[name]
|
27
|
+
contexts[name] ||= []
|
29
28
|
end
|
30
29
|
|
31
30
|
# Clear all named context validators off of the resource
|
@@ -6,7 +6,7 @@ module DataMapper
|
|
6
6
|
# @author Guy van den Berg
|
7
7
|
# @since 0.9
|
8
8
|
class UniquenessValidator < GenericValidator
|
9
|
-
include Assertions
|
9
|
+
include Extlib::Assertions
|
10
10
|
|
11
11
|
def initialize(field_name, options = {})
|
12
12
|
assert_kind_of 'scope', options[:scope], Array, Symbol if options.has_key?(:scope)
|
@@ -127,9 +127,9 @@ describe "Automatic Validation from Property Definition" do
|
|
127
127
|
it "should not auto add any validators if the option :auto_validation => false was given" do
|
128
128
|
klass = Class.new do
|
129
129
|
include DataMapper::Resource
|
130
|
-
property :id, Integer,
|
131
|
-
property :name, String,
|
132
|
-
property :bool,
|
130
|
+
property :id, Integer, :serial => true, :auto_validation => false
|
131
|
+
property :name, String, :nullable => false, :auto_validation => false
|
132
|
+
property :bool, DataMapper::Types::Boolean, :nullable => false, :auto_validation => false
|
133
133
|
end
|
134
134
|
klass.new.valid?.should == true
|
135
135
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy van den Berg
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-04 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.9
|
24
24
|
version:
|
25
25
|
description: DataMapper plugin for performing validations on data models
|
26
26
|
email:
|