mv-sqlite 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +159 -84
- data/lib/migration_validators/adapters/sqlite.rb +1 -1
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b14a84bb74774f0aa3ba2e61eaf11e1cb4d6841
|
4
|
+
data.tar.gz: 81b732865575ffb182352f98360ae2e9280def05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 707f1fb3fcd1f203f31b21b2627202a734484c1361836f543aa87e2765b172813980946b4c39547a873871903c2db5eec795e1da0ea8e8ebbe8cce526c4531b7
|
7
|
+
data.tar.gz: 326268c78ce09522453a739477f7ff94144961083127c4bec0ce87b7c87e63bb8a59695f8aba707ea07c248d4f90d1c193fb698e8873cfb8e155e655f0e3f134
|
data/README.rdoc
CHANGED
@@ -1,129 +1,204 @@
|
|
1
|
-
|
1
|
+
# Introduction
|
2
2
|
|
3
3
|
mv-sqlite is the SQLite driver for Migration Validators project (details here: https://github.com/vprokopchuk256/mv-core)
|
4
4
|
|
5
|
-
|
5
|
+
# Validators
|
6
6
|
|
7
|
-
|
7
|
+
### uniqueness
|
8
8
|
|
9
|
-
|
9
|
+
Examples:
|
10
10
|
|
11
|
-
|
11
|
+
validate uniqueness of the column 'column_name':
|
12
12
|
|
13
|
-
|
14
|
-
validate_column :table_name, :column_name,
|
15
|
-
|
13
|
+
```ruby
|
14
|
+
validate_column :table_name, :column_name, uniqueness: true
|
15
|
+
```
|
16
16
|
|
17
|
+
define validation as trigger with spefified failure message:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
validate_column :table_name, :column_name,
|
21
|
+
uniqueness: { message: 'Error message', as: :trigger }
|
22
|
+
```
|
23
|
+
|
24
|
+
define validation as unique index:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
validate_column :table_name, :column_name, uniqueness: { as: :index }
|
28
|
+
```
|
29
|
+
|
30
|
+
all above are available in a create and change table blocks:
|
31
|
+
|
32
|
+
```ruby
|
17
33
|
create_table :table_name do |t|
|
18
|
-
t.string :column_name, :
|
34
|
+
t.string :column_name, validates: { uniqueness: true }
|
19
35
|
end
|
36
|
+
```
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
change :table_name do |t|
|
40
|
+
t.change :column_name, :string, :validates: { uniqueness: false }
|
41
|
+
end
|
42
|
+
```
|
20
43
|
|
21
44
|
Options:
|
22
45
|
|
23
|
-
message
|
24
|
-
index_name
|
25
|
-
on
|
26
|
-
create_tigger_name
|
27
|
-
update_tigger_name
|
28
|
-
allow_nil
|
29
|
-
allow_blank
|
30
|
-
as
|
46
|
+
* `message` - text of the error message that will be shown if constraint violated. Ignored unless `:as == :trigger`
|
47
|
+
* `index_name` - name of the index that will be created for validator. Ignored unless `:as == :index`
|
48
|
+
* `on` - validation event. Possible values: `[:save, :update, :create]`. Ignored unless `:as == :trigger`. Default value `:save`
|
49
|
+
* `create_tigger_name` - name of the 'before insert' trigger that will be created if `:as == :trigger` && `:on` in `[:save, :create]`
|
50
|
+
* `update_tigger_name` - name of the 'before update' trigger that will be created if `:as == :trigger` && `:on` in `[:save, :update]`
|
51
|
+
* `allow_nil` - ignore validation for `nil` values. Ignored unless `:as == :trigger`. Default value: `false`
|
52
|
+
* `allow_blank` - ignore validation for blank values. Ignored unless `:as == :trigger`. Default value: `false`
|
53
|
+
* `as` - defines the way how constraint will be implemented. Possible values: `[:index, :trigger]`. Default value: `:index`
|
54
|
+
|
55
|
+
### length
|
56
|
+
|
57
|
+
Examples:
|
58
|
+
|
59
|
+
column value length should be more than 4 symbols and less than 9. Otherwise 'Wrong length message' error will be raised:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
validate_column :table_name, :column_name,
|
63
|
+
length: { in: 5..8,
|
64
|
+
message: 'Wrong length message' }
|
65
|
+
```
|
31
66
|
|
32
|
-
|
67
|
+
allow `NULL`:
|
33
68
|
|
34
|
-
|
69
|
+
```ruby
|
70
|
+
validate_column :table_name, :column_name,
|
71
|
+
length: { is: 3, allow_nil: true}
|
72
|
+
```
|
35
73
|
|
36
|
-
|
74
|
+
allow blank values:
|
37
75
|
|
38
|
-
|
39
|
-
validate_column :table_name, :column_name,
|
40
|
-
|
76
|
+
```ruby
|
77
|
+
validate_column :table_name, :column_name,
|
78
|
+
length: { maximum: 3,
|
79
|
+
too_long: 'Value is longer than 3 symbols' }
|
80
|
+
```
|
41
81
|
|
42
82
|
Options:
|
43
83
|
|
44
|
-
in
|
45
|
-
within
|
46
|
-
is
|
47
|
-
maximum
|
48
|
-
minimum
|
49
|
-
message
|
50
|
-
too_long
|
51
|
-
too_short
|
52
|
-
on
|
53
|
-
create_tigger_name
|
54
|
-
update_tigger_name
|
55
|
-
allow_nil
|
56
|
-
allow_blank
|
57
|
-
as
|
84
|
+
* `:in` - range or array that length of the value should be contained in.
|
85
|
+
* `:within` - synonym of `:in`
|
86
|
+
* `:is` - exact length of the value
|
87
|
+
* `:maximum` - maximum allowed length
|
88
|
+
* `:minimum` - minimum allowed length
|
89
|
+
* `:message` - message that should be shown if validation failed and specific message is not defined
|
90
|
+
* `:too_long` - message that will be shown if value longer than allowed. Ignored unless maximum value is defined
|
91
|
+
* `:too_short` - message that will be shown if value shorter than allowed. Ignored unless minimum value is defined
|
92
|
+
* `:on` - validation event. Possible values: `[:save, :update, :create]`. Default value: `:save`
|
93
|
+
* `:create_tigger_name` - Name of the 'before insert' trigger
|
94
|
+
* `:update_tigger_name` - Name of the 'before update' trigger
|
95
|
+
* `:allow_nil` - ignore validation for `nil` values. Default value: `false`
|
96
|
+
* `:allow_blank` - ignore validation for blank values. Default value: `false`
|
97
|
+
* `:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
58
98
|
|
59
|
-
|
99
|
+
### inclusion
|
60
100
|
|
61
|
-
|
101
|
+
Examples:
|
62
102
|
|
63
|
-
|
103
|
+
valid values array:
|
64
104
|
|
65
|
-
|
66
|
-
validate_column :table_name, :column_name, :
|
67
|
-
|
68
|
-
|
105
|
+
```ruby
|
106
|
+
validate_column :table_name, :column_name, inclusion: { in: [1, 2, 3] }
|
107
|
+
```
|
108
|
+
|
109
|
+
with failure message specified:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
validate_column :table_name, :column_name,
|
113
|
+
inclusion: { in: [1, 2, 3],
|
114
|
+
message: "Column 'column_name' should be equal to 1 or 2 or 3" }
|
115
|
+
```
|
69
116
|
|
70
117
|
Options:
|
71
118
|
|
72
|
-
in
|
73
|
-
message
|
74
|
-
on
|
75
|
-
create_tigger_name
|
76
|
-
update_tigger_name
|
77
|
-
allow_nil
|
78
|
-
allow_blank
|
79
|
-
as
|
119
|
+
* `in` - range or array that column value should be contained in.
|
120
|
+
* `message` - message that should be shown if validation failed
|
121
|
+
* `on` - validation event. Possible values: `[:save, :update, :create]`. Default value: :save
|
122
|
+
* `create_tigger_name` - Name of the 'before insert' trigger
|
123
|
+
* `update_tigger_name` - Name of the 'before update' trigger
|
124
|
+
* `allow_nil` - ignore validation for `nil` values. Default value: `false`
|
125
|
+
* `allow_blank` - ignore validation for blank values. Default value: `false`
|
126
|
+
* `as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
80
127
|
|
81
128
|
|
82
|
-
|
129
|
+
### exclusion
|
130
|
+
|
131
|
+
exclude 1, 2, and 3:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
validate_column :table_name, :column_name, exclusion: { in: [1, 2, 3] }
|
135
|
+
```
|
136
|
+
|
137
|
+
exclude values with specified failure message:
|
83
138
|
|
84
|
-
|
139
|
+
```ruby
|
140
|
+
validate_column :table_name, :column_name,
|
141
|
+
exclusion: {
|
142
|
+
in: [1, 2, 3],
|
143
|
+
:message => "Column 'column_name' should not be equal to 1 or 2 or 3"
|
144
|
+
}
|
145
|
+
```
|
85
146
|
|
86
|
-
|
147
|
+
performs verification on update only:
|
87
148
|
|
88
|
-
|
89
|
-
validate_column :table_name, :column_name,
|
90
|
-
|
91
|
-
|
149
|
+
```ruby
|
150
|
+
validate_column :table_name, :column_name,
|
151
|
+
exclusion: { in: [1, 2, 3],
|
152
|
+
on: :update }
|
153
|
+
```
|
92
154
|
|
93
155
|
Options:
|
94
156
|
|
95
|
-
in
|
96
|
-
message
|
97
|
-
on
|
98
|
-
create_tigger_name
|
99
|
-
update_tigger_name
|
100
|
-
allow_nil
|
101
|
-
allow_blank
|
102
|
-
as
|
157
|
+
* `in` - range or array that column value should NOT be contained in.
|
158
|
+
* `message` - message that should be shown if validation failed
|
159
|
+
* `on` - validation event. Possible values: `[:save, :update, :create]`. Default value: `:save`
|
160
|
+
* `create_tigger_name` - Name of the 'before insert' trigger
|
161
|
+
* `update_tigger_name` - Name of the 'before update' trigger
|
162
|
+
* `allow_nil` - ignore validation for `nil` values. Default value: `false`
|
163
|
+
* `allow_blank` - ignore validation for blank values. Default value: `false`
|
164
|
+
* `as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
103
165
|
|
104
|
-
|
166
|
+
### presence
|
105
167
|
|
106
|
-
|
168
|
+
Examples:
|
107
169
|
|
108
|
-
|
170
|
+
simple presence validator:
|
109
171
|
|
110
|
-
|
111
|
-
validate_column :table_name, :column_name, :
|
112
|
-
|
113
|
-
|
114
|
-
|
172
|
+
```ruby
|
173
|
+
validate_column :table_name, :column_name, presence: true
|
174
|
+
```
|
175
|
+
|
176
|
+
with failure message:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
validate_column :table_name, :column_name,
|
180
|
+
presence: { message: 'value should not be empty' }
|
181
|
+
```
|
182
|
+
|
183
|
+
performs verification only when new record is inserted:
|
184
|
+
|
185
|
+
```ruby
|
186
|
+
validate_column :table_name, :column_name,
|
187
|
+
presence: { message: 'value should not be empty',
|
188
|
+
on: :create }
|
189
|
+
```
|
115
190
|
|
116
191
|
Options:
|
117
192
|
|
118
|
-
message
|
119
|
-
on
|
120
|
-
create_tigger_name
|
121
|
-
update_tigger_name
|
122
|
-
allow_nil
|
123
|
-
allow_blank
|
124
|
-
as
|
193
|
+
* `:message` - message that should be shown if validation failed
|
194
|
+
* `:on` - validation event. Possible values: `[:save, :update, :create]`. Default value: `:save`
|
195
|
+
* `:create_tigger_name` - Name of the 'before insert' trigger
|
196
|
+
* `:update_tigger_name` - Name of the 'before update' trigger
|
197
|
+
* `:allow_nil` - ignore validation for `nil` values. Default value: `false`
|
198
|
+
* `:allow_blank` - ignore validation for blank values. Default value: `false`
|
199
|
+
* `:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
125
200
|
|
126
|
-
|
201
|
+
## Contributing to mv-sqlite
|
127
202
|
|
128
203
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
129
204
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
@@ -133,7 +208,7 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
133
208
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
134
209
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
135
210
|
|
136
|
-
|
211
|
+
## Copyright
|
137
212
|
|
138
213
|
Copyright (c) 2011 Valeriy Prokopchuk. See LICENSE.txt for
|
139
214
|
further details.
|
@@ -44,7 +44,7 @@ module MigrationValidators
|
|
44
44
|
end
|
45
45
|
|
46
46
|
|
47
|
-
route :
|
47
|
+
route :presence, :trigger, :default => true do
|
48
48
|
to :insert_trigger, :if => {:on => [:save, :create, nil]}
|
49
49
|
to :update_trigger, :if => {:on => [:save, :update, nil]}
|
50
50
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mv-sqlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valeriy Prokopchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mv-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jeweler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '2.0'
|
55
55
|
description: Migration Validators project sqlite driver
|
56
56
|
email: vprokopchuk@gmail.com
|
57
57
|
executables: []
|
@@ -60,10 +60,10 @@ extra_rdoc_files:
|
|
60
60
|
- LICENSE.txt
|
61
61
|
- README.rdoc
|
62
62
|
files:
|
63
|
-
- lib/migration_validators/adapters/sqlite.rb
|
64
|
-
- lib/mv-sqlite.rb
|
65
63
|
- LICENSE.txt
|
66
64
|
- README.rdoc
|
65
|
+
- lib/migration_validators/adapters/sqlite.rb
|
66
|
+
- lib/mv-sqlite.rb
|
67
67
|
homepage: http://github.com/vprokopchuk256/mv-sqlite
|
68
68
|
licenses:
|
69
69
|
- MIT
|
@@ -84,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.4.2
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
|
-
summary: Migration Validators project
|
90
|
+
summary: Migration Validators project. SQLite driver
|
91
91
|
test_files: []
|