sequel_validation_helpers_block 1.0.0 → 1.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/lib/sequel_validation_helpers_block.rb +2 -2
- data/spec/sequel_validation_helpers_block_spec.rb +19 -5
- metadata +30 -38
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aef24a97ede9558d4e5acf778626d24d19705f4e
|
4
|
+
data.tar.gz: 8b890314e88074541e572c18ad73713e57940877
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8b15a04a574db9706ea5369a518901ee7f52cbb608234ce66cb79eddb472a217174f20ae462081e9bb769fe9608a220c67c7afc9fd71058b3ccdcc29705cae0d
|
7
|
+
data.tar.gz: 152365214669bdd37425a03c423c89aa7b06917732b57e4961cbac95cef9df880ec8d2f5edb0629f0e2e02df5b10919b71b5d45317b36c117bcea4b052e9e826
|
data/LICENSE
CHANGED
@@ -55,10 +55,10 @@ module Sequel
|
|
55
55
|
# run for the related attribute on the related object.
|
56
56
|
class ValidationHelpersValidationsBlock < BasicObject
|
57
57
|
# validation_helpers methods that do not require a leading argument.
|
58
|
-
VALIDATION_HELPERS_NO_ARG_METHODS = [:integer, :
|
58
|
+
VALIDATION_HELPERS_NO_ARG_METHODS = [:integer, :schema_types, :numeric, :presence, :unique].freeze
|
59
59
|
|
60
60
|
# validation_helpers methods that require a leading argument
|
61
|
-
VALIDATION_HELPERS_1_ARG_METHODS = [:exact_length, :format, :includes, :length_range, :max_length, :min_length].freeze
|
61
|
+
VALIDATION_HELPERS_1_ARG_METHODS = [:exact_length, :format, :includes, :length_range, :max_length, :min_length, :type].freeze
|
62
62
|
|
63
63
|
# Store the object and attribute and instance_eval the block.
|
64
64
|
def initialize(obj, attr, &block)
|
@@ -3,6 +3,17 @@ require 'sequel'
|
|
3
3
|
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
4
|
Sequel.extension :blank
|
5
5
|
|
6
|
+
if defined?(RSpec)
|
7
|
+
require 'rspec/version'
|
8
|
+
if RSpec::Version::STRING >= '2.11.0'
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.expect_with :rspec do |c|
|
11
|
+
c.syntax = :should
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
6
17
|
describe "Sequel::Plugins::ValidationHelpersBlock" do
|
7
18
|
before do
|
8
19
|
@db = Sequel::Database.new
|
@@ -33,7 +44,7 @@ describe "Sequel::Plugins::ValidationHelpersBlock" do
|
|
33
44
|
end
|
34
45
|
end
|
35
46
|
@m.should_not be_valid
|
36
|
-
@m.errors.should == {:name=>["is not present", "is
|
47
|
+
@m.errors.should == {:name=>["is not present", "is not present"], :date=>["is invalid"], :number=>["is not present", "is not a number"]}
|
37
48
|
@m.set(:name=>'1234567890-', :number=>'a', :date=>'Tuesday')
|
38
49
|
@m.should_not be_valid
|
39
50
|
@m.errors.should == {:name=>["is longer than 10 characters"], :date=>["is invalid"], :number=>["is not a number"]}
|
@@ -69,11 +80,13 @@ describe "Sequel::Plugins::ValidationHelpersBlock" do
|
|
69
80
|
@c.set_validations do
|
70
81
|
validates do
|
71
82
|
name do
|
83
|
+
unique
|
72
84
|
max_length 12
|
73
85
|
exact_length 10
|
74
86
|
min_length 8
|
75
87
|
length_range 9..11
|
76
|
-
|
88
|
+
type String
|
89
|
+
schema_types
|
77
90
|
end
|
78
91
|
date do
|
79
92
|
format %r{\d\d/\d\d/\d\d\d\d}
|
@@ -83,7 +96,6 @@ describe "Sequel::Plugins::ValidationHelpersBlock" do
|
|
83
96
|
presence
|
84
97
|
integer
|
85
98
|
numeric
|
86
|
-
not_string
|
87
99
|
end
|
88
100
|
end
|
89
101
|
end
|
@@ -98,11 +110,13 @@ describe "Sequel::Plugins::ValidationHelpersBlock" do
|
|
98
110
|
end
|
99
111
|
})
|
100
112
|
@c.dataset = ds
|
113
|
+
@c.db_schema[:name] = {:type => :string}
|
114
|
+
@m.name = ''
|
101
115
|
@m.should_not be_valid
|
102
|
-
@m.errors.should == {:name=>["is
|
116
|
+
@m.errors.should == {:name=>["is already taken", "is not 10 characters", "is shorter than 8 characters", "is too short or too long"], :date=>["is invalid", "is not in range or set: [\"10/11/2009\"]"], :number=>["is not present", "is not a number", "is not a number"]}
|
103
117
|
@m.set(:name=>'123456789', :date=>'10/12/2009', :number=>'12')
|
104
118
|
@m.should_not be_valid
|
105
|
-
@m.errors.should == {:name=>["is
|
119
|
+
@m.errors.should == {:name=>["is already taken", "is not 10 characters"], :date=>["is not in range or set: [\"10/11/2009\"]"]}
|
106
120
|
@m.set(:name=>'1234567890', :date=>'10/11/2009', :number=>12)
|
107
121
|
@m.should be_valid
|
108
122
|
@m.errors.should == {}
|
metadata
CHANGED
@@ -1,64 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_validation_helpers_block
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
date: 2009-10-27 00:00:00 -07:00
|
13
|
-
default_executable:
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
14
12
|
dependencies: []
|
15
|
-
|
16
13
|
description:
|
17
14
|
email: code@jeremyevans.net
|
18
15
|
executables: []
|
19
|
-
|
20
16
|
extensions: []
|
21
|
-
|
22
17
|
extra_rdoc_files: []
|
23
|
-
|
24
|
-
files:
|
18
|
+
files:
|
25
19
|
- LICENSE
|
26
20
|
- lib/sequel_validation_helpers_block.rb
|
27
21
|
- spec/sequel_validation_helpers_block_spec.rb
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
homepage: https://github.com/jeremyevans/sequel_validation_helpers_block
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
32
26
|
post_install_message:
|
33
|
-
rdoc_options:
|
34
|
-
- --inline-source
|
35
|
-
- --line-numbers
|
36
|
-
- --title
|
37
|
-
-
|
38
|
-
|
27
|
+
rdoc_options:
|
28
|
+
- "--inline-source"
|
29
|
+
- "--line-numbers"
|
30
|
+
- "--title"
|
31
|
+
- 'Sequel validation_helpers_block: Allows easy determination of which validation
|
32
|
+
rules apply to a given column, at the expense of increased verbosity'
|
33
|
+
- "--main"
|
39
34
|
- Sequel::Plugins::ValidationHelpersBlock
|
40
35
|
- lib/sequel_validation_helpers_block.rb
|
41
36
|
- LICENSE
|
42
|
-
require_paths:
|
37
|
+
require_paths:
|
43
38
|
- lib
|
44
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
46
41
|
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version:
|
49
|
-
|
50
|
-
|
51
|
-
requirements:
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
52
46
|
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
version:
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
56
49
|
requirements: []
|
57
|
-
|
58
50
|
rubyforge_project:
|
59
|
-
rubygems_version:
|
51
|
+
rubygems_version: 2.4.5
|
60
52
|
signing_key:
|
61
|
-
specification_version:
|
62
|
-
summary: Allows easy determination of which validation rules apply to a given column,
|
53
|
+
specification_version: 4
|
54
|
+
summary: Allows easy determination of which validation rules apply to a given column,
|
55
|
+
at the expense of increased verbosity
|
63
56
|
test_files: []
|
64
|
-
|