mv-mysql 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.md +256 -0
- data/lib/migration_validators/adapters/mysql.rb +1 -1
- metadata +19 -19
- data/README.rdoc +0 -162
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abdfb79935b4424eb3cd33e0e0106f889ca7821
|
4
|
+
data.tar.gz: 49f6d0fdbd344bbc69acfd15bf9b683e26cc9ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 121e6abffa04e9b126beff0a739192f356e1a7bb77c2a9247fc9818c4b3ad76f31a408b3b7db951857869de1c28fba41e3282e1c56029e6dc70d55efa0103089
|
7
|
+
data.tar.gz: 9db74d62911dcd927c259ba641c4914c388b12819f35b54672877538a2883e83b3fc8d7b4e72ae8f10e3b313b5d2dd066adaf598ee5024a43081976eb18c5fb8
|
data/README.md
ADDED
@@ -0,0 +1,256 @@
|
|
1
|
+
# Introduction
|
2
|
+
|
3
|
+
mv-mysql is the MySQL driver for Migration Validators project (details here: https://github.com/vprokopchuk256/mv-core)
|
4
|
+
|
5
|
+
# Validators
|
6
|
+
|
7
|
+
### uniqueness
|
8
|
+
|
9
|
+
Examples:
|
10
|
+
|
11
|
+
validate uniqueness of the column 'column_name':
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
validate_column :table_name, :column_name, uniqueness: true
|
15
|
+
```
|
16
|
+
|
17
|
+
define validation as trigger with specified 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
|
33
|
+
create_table :table_name do |t|
|
34
|
+
t.string :column_name, validates: { uniqueness: true }
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
change :table_name do |t|
|
40
|
+
t.change :column_name, :string, :validates: { uniqueness: false }
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
Options:
|
45
|
+
|
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
|
+
```
|
66
|
+
|
67
|
+
allow `NULL`:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
validate_column :table_name, :column_name,
|
71
|
+
length: { is: 3, allow_nil: true}
|
72
|
+
```
|
73
|
+
|
74
|
+
allow blank values:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
validate_column :table_name, :column_name,
|
78
|
+
length: { maximum: 3,
|
79
|
+
too_long: 'Value is longer than 3 symbols' }
|
80
|
+
```
|
81
|
+
|
82
|
+
Options:
|
83
|
+
|
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]`
|
98
|
+
|
99
|
+
### inclusion
|
100
|
+
|
101
|
+
Examples:
|
102
|
+
|
103
|
+
valid values array:
|
104
|
+
|
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
|
+
```
|
116
|
+
|
117
|
+
Options:
|
118
|
+
|
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]`
|
127
|
+
|
128
|
+
|
129
|
+
### exclusion
|
130
|
+
|
131
|
+
Examples:
|
132
|
+
|
133
|
+
exclude 1, 2, and 3:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
validate_column :table_name, :column_name, exclusion: { in: [1, 2, 3] }
|
137
|
+
```
|
138
|
+
|
139
|
+
exclude values with specified failure message:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
validate_column :table_name, :column_name,
|
143
|
+
exclusion: {
|
144
|
+
in: [1, 2, 3],
|
145
|
+
message: "Column 'column_name' should not be equal to 1 or 2 or 3"
|
146
|
+
}
|
147
|
+
```
|
148
|
+
|
149
|
+
performs verification on update only:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
validate_column :table_name, :column_name,
|
153
|
+
exclusion: { in: [1, 2, 3],
|
154
|
+
on: :update }
|
155
|
+
```
|
156
|
+
|
157
|
+
Options:
|
158
|
+
|
159
|
+
* `:in` - range or array that column value should NOT be contained in.
|
160
|
+
message: message that should be shown if validation failed
|
161
|
+
* `:on` - validation event. Possible values `[:save, :update, :create]`. Default value: :save
|
162
|
+
*`:create_tigger_name` - name of the 'before insert' trigger
|
163
|
+
*`:update_tigger_name` - name of the 'before update' trigger
|
164
|
+
*`:allow_nil` - ignore validation for nil values. Default value: false
|
165
|
+
*`:allow_blank` - ignore validation for blank values. Default value: false
|
166
|
+
*`:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
167
|
+
|
168
|
+
### presence
|
169
|
+
|
170
|
+
Examples:
|
171
|
+
|
172
|
+
simple presence validator:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
validate_column :table_name, :column_name, presence: true
|
176
|
+
```
|
177
|
+
|
178
|
+
with failure message:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
validate_column :table_name, :column_name,
|
182
|
+
:presence: { message: 'value should not be empty' }
|
183
|
+
```
|
184
|
+
|
185
|
+
performs verification only when new record is inserted:
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
validate_column :table_name, :column_name,
|
189
|
+
presence: { message: 'value should not be empty',
|
190
|
+
on: :create }
|
191
|
+
```
|
192
|
+
|
193
|
+
Options:
|
194
|
+
|
195
|
+
* `:message` - message that should be shown if validation failed
|
196
|
+
`:on` validation event. Possible values `[:save, :update, :create]`. Default value: `:save`
|
197
|
+
* `:create_tigger_name` - name of the 'before insert' trigger
|
198
|
+
* `:update_tigger_name` - name of the 'before update' trigger
|
199
|
+
* `:allow_nil` - ignore validation for nil values. Default value: false
|
200
|
+
* `:allow_blank` - ignore validation for blank values. Default value: `false`
|
201
|
+
* `:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
202
|
+
|
203
|
+
### format
|
204
|
+
|
205
|
+
Allows to define regular expression that column value will be mathed with
|
206
|
+
|
207
|
+
Example:
|
208
|
+
|
209
|
+
simple custom format validator:
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
validate_column :table_name, :column_name, format: { with: /word/ }
|
213
|
+
```
|
214
|
+
|
215
|
+
with custom failure message:
|
216
|
+
|
217
|
+
```ruby
|
218
|
+
validate_column :table_name, :column_name,
|
219
|
+
format: { with: /word/,
|
220
|
+
messsage: 'Column_name value should contain start word' }
|
221
|
+
```
|
222
|
+
|
223
|
+
implemented as trigger:
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
validate_column :table_name, :column_name,
|
227
|
+
format: { with: /word/,
|
228
|
+
messsage: 'Column_name value should contain start word', as: :trigger }
|
229
|
+
```
|
230
|
+
|
231
|
+
Options:
|
232
|
+
|
233
|
+
* `:with` - regular expression that column value should be matched to
|
234
|
+
* `:message` - message that should be shown if validation failed
|
235
|
+
* `:on` - validation event. Possible values `[:save, :update, :create]`. Default value: `:save`
|
236
|
+
* `:create_tigger_name` - name of the 'before insert' trigger
|
237
|
+
* `:update_tigger_name` - name of the 'before update' trigger
|
238
|
+
* `:allow_nil` - ignore validation for nil values. Default value: `false`
|
239
|
+
* `:allow_blank` - ignore validation for blank values. Default value: `false`
|
240
|
+
* `:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
241
|
+
|
242
|
+
## Contributing to mv-mysql
|
243
|
+
|
244
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
245
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
246
|
+
* Fork the project
|
247
|
+
* Start a feature/bugfix branch
|
248
|
+
* Commit and push until you are happy with your contribution
|
249
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
250
|
+
* 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.
|
251
|
+
|
252
|
+
## Copyright
|
253
|
+
|
254
|
+
Copyright (c) 2011 Valeriy Prokopchuk. See LICENSE.txt for
|
255
|
+
further details.
|
256
|
+
|
@@ -66,7 +66,7 @@ module MigrationValidators
|
|
66
66
|
end
|
67
67
|
|
68
68
|
|
69
|
-
route :
|
69
|
+
route :presence, :trigger, :default => true do
|
70
70
|
to :insert_trigger, :if => {:on => [:save, :create, nil]}
|
71
71
|
to :update_trigger, :if => {:on => [:save, :update, nil]}
|
72
72
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mv-mysql
|
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: mysql2
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.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: '0'
|
26
|
+
version: '0.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: 1.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: 1.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 mysql driver
|
56
56
|
email: vprokopchuk@gmail.com
|
57
57
|
executables: []
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files:
|
60
60
|
- LICENSE.txt
|
61
|
-
- README.
|
61
|
+
- README.md
|
62
62
|
files:
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
63
65
|
- lib/migration_validators/adapters/mysql.rb
|
64
66
|
- lib/mv-mysql.rb
|
65
|
-
- LICENSE.txt
|
66
|
-
- README.rdoc
|
67
67
|
homepage: http://github.com/vprokopchuk256/mv-mysql
|
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. MySQL driver
|
91
91
|
test_files: []
|
data/README.rdoc
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
= Introduction
|
2
|
-
|
3
|
-
mv-mysql is the MySQL driver for Migration Validators project (details here: https://github.com/vprokopchuk256/mv-core)
|
4
|
-
|
5
|
-
= Validators
|
6
|
-
|
7
|
-
=== uniqueness
|
8
|
-
|
9
|
-
Value uniqueness validation
|
10
|
-
|
11
|
-
Usage:
|
12
|
-
|
13
|
-
validate_column :table_name, :column_name, :uniqueness => true
|
14
|
-
validate_column :table_name, :column_name, :uniqueness => {:message => 'Error message', :as => :trigger}
|
15
|
-
validate_column :table_name, :column_name, :uniqueness => {:as => :index}
|
16
|
-
|
17
|
-
create_table :table_name do |t|
|
18
|
-
t.string :column_name, :validates => {uniqueness => true}
|
19
|
-
end
|
20
|
-
|
21
|
-
Options:
|
22
|
-
|
23
|
-
message: text of the error message that will be shown if constraint violated. Ignored unless :as == :trigger
|
24
|
-
index_name: name of the index that will be created for validator. Ignored unless :as == :index
|
25
|
-
on: validation event. Possible values [:save, :update, :create]. Ignored unless :as == :trigger. Default value :save
|
26
|
-
create_tigger_name: Name of the 'before insert' trigger that will be created if :as == :trigger && :on in [:save, :create]
|
27
|
-
update_tigger_name: Name of the 'before update' trigger that will be created if :as == :trigger && :on in [:save, :update]
|
28
|
-
allow_nil: ignore validation for nil values. Ignored unless :as == :trigger. Default value: false
|
29
|
-
allow_blank: ignore validation for blank values. Ignored unless :as == :trigger. Default value: false
|
30
|
-
as: defines the way how constraint will be implemented. Possible values: [:index, :trigger]. Default value: :index
|
31
|
-
|
32
|
-
=== length
|
33
|
-
|
34
|
-
Value length validation
|
35
|
-
|
36
|
-
Usage:
|
37
|
-
|
38
|
-
validate_column :table_name, :column_name, :length => {:in => 5..8, :message => "Wrong length message"}
|
39
|
-
validate_column :table_name, :column_name, :length => {:is => 3, :allow_nil => true}
|
40
|
-
validate_column :table_name, :column_name, :length => {:maximum => 3, :too_long => "Value is longer than 3 symbols"}
|
41
|
-
|
42
|
-
Options:
|
43
|
-
|
44
|
-
in: range or array that length of the value should be contained in.
|
45
|
-
within: synonym of :in
|
46
|
-
is: exact length of the value
|
47
|
-
maximum: maximum allowed length
|
48
|
-
minimum: minimum allowed length
|
49
|
-
message: message that should be shown if validation failed and specific message is not defined
|
50
|
-
too_long: message that will be shown if value longer than allowed. Ignored unless maximum value is defined
|
51
|
-
too_short: message that will be shown if value shorter than allowed. Ignored unless minimum value is defined
|
52
|
-
on: validation event. Possible values [:save, :update, :create]. Default value: :save
|
53
|
-
create_tigger_name: Name of the 'before insert' trigger
|
54
|
-
update_tigger_name: Name of the 'before update' trigger
|
55
|
-
allow_nil: ignore validation for nil values. Default value: false
|
56
|
-
allow_blank: ignore validation for blank values. Default value: false
|
57
|
-
as: defines the way how constraint will be implemented. Possible values: [:trigger]
|
58
|
-
|
59
|
-
=== inclusion
|
60
|
-
|
61
|
-
Value inclusion validation
|
62
|
-
|
63
|
-
Usage:
|
64
|
-
|
65
|
-
validate_column :table_name, :column_name, :inclusion => {:in => [1, 2, 3]}
|
66
|
-
validate_column :table_name, :column_name, :inclusion => {:in => [1, 2, 3], :message => "Column 'column_name' should be equal to 1 or 2 or 3"}
|
67
|
-
validate_column :table_name, :column_name, :inclusion => {:in => [1, 2, 3], :on => :update, :as => :check}
|
68
|
-
validate_column :table_name, :column_name, :inclusion => {:in => 1..3, :on => :create, :as => :trigger}
|
69
|
-
|
70
|
-
Options:
|
71
|
-
|
72
|
-
in: range or array that column value should be contained in.
|
73
|
-
message: message that should be shown if validation failed
|
74
|
-
on: validation event. Possible values [:save, :update, :create]. Default value: :save
|
75
|
-
create_tigger_name: Name of the 'before insert' trigger
|
76
|
-
update_tigger_name: Name of the 'before update' trigger
|
77
|
-
allow_nil: ignore validation for nil values. Default value: false
|
78
|
-
allow_blank: ignore validation for blank values. Default value: false
|
79
|
-
as: defines the way how constraint will be implemented. Possible values: [:trigger]
|
80
|
-
|
81
|
-
|
82
|
-
=== exclusion
|
83
|
-
|
84
|
-
Value exclusion validation
|
85
|
-
|
86
|
-
Usage:
|
87
|
-
|
88
|
-
validate_column :table_name, :column_name, :exclusion => {:in => [1, 2, 3]}
|
89
|
-
validate_column :table_name, :column_name, :exclusion => {:in => [1, 2, 3], :message => "Column 'column_name' should not be equal to 1 or 2 or 3"}
|
90
|
-
validate_column :table_name, :column_name, :exclusion => {:in => [1, 2, 3], :on => :update, :as => :check}
|
91
|
-
validate_column :table_name, :column_name, :exclusion => {:in => 1..3, :on => :create, :as => :trigger}
|
92
|
-
|
93
|
-
Options:
|
94
|
-
|
95
|
-
in: range or array that column value should NOT be contained in.
|
96
|
-
message: message that should be shown if validation failed
|
97
|
-
on: validation event. Possible values [:save, :update, :create]. Default value: :save
|
98
|
-
create_tigger_name: Name of the 'before insert' trigger
|
99
|
-
update_tigger_name: Name of the 'before update' trigger
|
100
|
-
allow_nil: ignore validation for nil values. Default value: false
|
101
|
-
allow_blank: ignore validation for blank values. Default value: false
|
102
|
-
as: defines the way how constraint will be implemented. Possible values: [:trigger]
|
103
|
-
|
104
|
-
=== presense
|
105
|
-
|
106
|
-
Value presense validation
|
107
|
-
|
108
|
-
Usage:
|
109
|
-
|
110
|
-
validate_column :table_name, :column_name, :presense => true
|
111
|
-
validate_column :table_name, :column_name, :presense => {:message => "value should not be empty"}
|
112
|
-
validate_column :table_name, :column_name, :presense => {:message => "value should not be empty", :as=> :trigger}
|
113
|
-
validate_column :table_name, :column_name, :presense => {:message => "value should not be empty", :as=> :trigger, :on => :create}
|
114
|
-
|
115
|
-
|
116
|
-
Options:
|
117
|
-
|
118
|
-
message: message that should be shown if validation failed
|
119
|
-
on: validation event. Possible values [:save, :update, :create]. Default value: :save
|
120
|
-
create_tigger_name: Name of the 'before insert' trigger
|
121
|
-
update_tigger_name: Name of the 'before update' trigger
|
122
|
-
allow_nil: ignore validation for nil values. Default value: false
|
123
|
-
allow_blank: ignore validation for blank values. Default value: false
|
124
|
-
as: defines the way how constraint will be implemented. Possible values: [:trigger]
|
125
|
-
|
126
|
-
=== format
|
127
|
-
|
128
|
-
Allows to define regular expression that column value will be mathed with
|
129
|
-
|
130
|
-
Usage:
|
131
|
-
|
132
|
-
validate_column :table_name, :column_name, :format => {:with => /word/}
|
133
|
-
validate_column :table_name, :column_name, :format => {:with => /word/, :messsage => "Column_name value should contain start word"}
|
134
|
-
validate_column :table_name, :column_name, :format => {:with => /word/, :messsage => "Column_name value should contain start word", :as => :trigger}
|
135
|
-
|
136
|
-
|
137
|
-
Options:
|
138
|
-
|
139
|
-
with: regular expression that column value should be matched to
|
140
|
-
message: message that should be shown if validation failed
|
141
|
-
on: validation event. Possible values [:save, :update, :create]. Default value: :save
|
142
|
-
create_tigger_name: Name of the 'before insert' trigger
|
143
|
-
update_tigger_name: Name of the 'before update' trigger
|
144
|
-
allow_nil: ignore validation for nil values. Default value: false
|
145
|
-
allow_blank: ignore validation for blank values. Default value: false
|
146
|
-
as: defines the way how constraint will be implemented. Possible values: [:trigger]
|
147
|
-
|
148
|
-
== Contributing to mv-mysql
|
149
|
-
|
150
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
151
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
152
|
-
* Fork the project
|
153
|
-
* Start a feature/bugfix branch
|
154
|
-
* Commit and push until you are happy with your contribution
|
155
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
156
|
-
* 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.
|
157
|
-
|
158
|
-
== Copyright
|
159
|
-
|
160
|
-
Copyright (c) 2011 Valeriy Prokopchuk. See LICENSE.txt for
|
161
|
-
further details.
|
162
|
-
|