mv-sqlite 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +348 -117
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d7c3516a357006e5885434ecd2295a0cd1d795f
|
4
|
+
data.tar.gz: 710018cae984e45c333825a08aeb9fc5fb9d2bd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef9f6cf9fd3880c44f6d483a1e2582e16cbc22d5a07c87779655e02beda8e4596740880e24f06e779599e46703758c12d3a284edf7be0868ed1cd5462e2633ea
|
7
|
+
data.tar.gz: ddad7dd1b74762e5e93285db43094d2b7d7c73d2d609fc36e046e0c093bf6d192b6bf2c271bb5bf239eb999a8e87069cef82d80b4e25dd0a9f66dbdf2d4fa314
|
data/README.md
CHANGED
@@ -2,11 +2,23 @@
|
|
2
2
|
[![Coverage Status](https://coveralls.io/repos/vprokopchuk256/mv-sqlite/badge.png?branch=master)](https://coveralls.io/r/vprokopchuk256/mv-sqlite?branch=master)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/mv-sqlite.svg)](http://badge.fury.io/rb/mv-sqlite)
|
4
4
|
|
5
|
-
#
|
5
|
+
# `Migration Validators` project. SQLite driver.
|
6
6
|
|
7
|
-
|
7
|
+
Define validations directly in DB as SQLite constraints and integrate them into your model transparently. See [mv-core](https://github.com/vprokopchuk256/mv-core) for details. There you will be able to review high level project information. Below you can see details of the migration validations that are supported by SQLite driver.
|
8
8
|
|
9
|
-
#
|
9
|
+
#Table Of Contents
|
10
|
+
* [Validations](#validations)
|
11
|
+
* [uniqueness](#uniqueness)
|
12
|
+
* [length](#length)
|
13
|
+
* [inclusion](#inclusion)
|
14
|
+
* [exclusion](#exclusion)
|
15
|
+
* [presence](#presence)
|
16
|
+
* [absence](#absence)
|
17
|
+
* [custom](#custom)
|
18
|
+
* [Version History](#version history)
|
19
|
+
* [Contributing](#contributing)
|
20
|
+
|
21
|
+
# Validations
|
10
22
|
|
11
23
|
### uniqueness
|
12
24
|
|
@@ -15,41 +27,71 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
15
27
|
validate uniqueness of the column 'column_name':
|
16
28
|
|
17
29
|
```ruby
|
18
|
-
|
30
|
+
def up
|
31
|
+
validates :table_name, :column_name, uniqueness: true
|
32
|
+
end
|
33
|
+
|
34
|
+
def down
|
35
|
+
validates :table_name, :column_name, uniqueness: false
|
36
|
+
end
|
19
37
|
```
|
20
38
|
|
21
39
|
define validation as trigger with specified failure message:
|
22
40
|
|
23
41
|
```ruby
|
24
|
-
|
25
|
-
|
42
|
+
def up
|
43
|
+
validates :table_name, :column_name,
|
44
|
+
uniqueness: { message: 'Error message', as: :trigger }
|
45
|
+
end
|
46
|
+
|
47
|
+
def down
|
48
|
+
validates :table_name, :column_name, uniqueness: false
|
49
|
+
end
|
26
50
|
```
|
27
51
|
|
28
52
|
define validation as unique index:
|
29
53
|
|
30
54
|
```ruby
|
31
|
-
|
55
|
+
def up
|
56
|
+
validates :table_name, :column_name, uniqueness: { as: :index }
|
57
|
+
end
|
58
|
+
|
59
|
+
def down
|
60
|
+
validates :table_name, :column_name, uniqueness: false
|
61
|
+
end
|
32
62
|
```
|
33
63
|
|
34
64
|
all above are available in a create and change table blocks:
|
35
65
|
|
36
66
|
```ruby
|
37
|
-
|
38
|
-
|
67
|
+
def change
|
68
|
+
create_table :table_name do |t|
|
69
|
+
t.string :column_name, validates: { uniqueness: true }
|
70
|
+
end
|
39
71
|
end
|
40
72
|
```
|
41
73
|
|
42
74
|
```ruby
|
43
|
-
|
44
|
-
|
75
|
+
def up
|
76
|
+
change :table_name do |t|
|
77
|
+
t.change :column_name, :string, :validates: { uniqueness: true }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def down
|
82
|
+
change :table_name do |t|
|
83
|
+
t.change :column_name, :string, :validates: { uniqueness: false }
|
84
|
+
end
|
45
85
|
end
|
46
86
|
```
|
47
87
|
|
48
88
|
simplifications (version >= 2.1 is required):
|
49
89
|
|
50
90
|
```ruby
|
51
|
-
|
52
|
-
|
91
|
+
def change
|
92
|
+
create_table :table_name do |t|
|
93
|
+
t.string :column_name, uniqueness: true
|
94
|
+
end
|
53
95
|
end
|
54
96
|
```
|
55
97
|
|
@@ -71,49 +113,79 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
71
113
|
column value length should be more than 4 symbols and less than 9. Otherwise 'Wrong length message' error will be raised:
|
72
114
|
|
73
115
|
```ruby
|
74
|
-
|
75
|
-
|
76
|
-
|
116
|
+
def up
|
117
|
+
validates :table_name, :column_name,
|
118
|
+
length: { in: 5..8,
|
119
|
+
message: 'Wrong length message' }
|
120
|
+
end
|
121
|
+
|
122
|
+
def down
|
123
|
+
validates :table_name, :column_name, length: false
|
124
|
+
end
|
77
125
|
```
|
78
126
|
|
79
127
|
allow `NULL`:
|
80
128
|
|
81
129
|
```ruby
|
82
|
-
|
83
|
-
|
130
|
+
def up
|
131
|
+
validates :table_name, :column_name,
|
132
|
+
length: { is: 3, allow_nil: true}
|
133
|
+
end
|
134
|
+
|
135
|
+
def down
|
136
|
+
validates :table_name, :column_name, length: false
|
137
|
+
end
|
84
138
|
```
|
85
139
|
|
86
140
|
allow blank values:
|
87
141
|
|
88
142
|
```ruby
|
89
|
-
|
90
|
-
|
91
|
-
|
143
|
+
def up
|
144
|
+
validates :table_name, :column_name,
|
145
|
+
length: { maximum: 3,
|
146
|
+
too_long: 'Value is longer than 3 symbols' }
|
147
|
+
end
|
148
|
+
|
149
|
+
def down
|
150
|
+
validates :table_name, :column_name, length: false
|
151
|
+
end
|
92
152
|
```
|
93
153
|
|
94
154
|
all above are available in a create and change table blocks:
|
95
155
|
|
96
156
|
```ruby
|
97
|
-
|
98
|
-
|
157
|
+
def change
|
158
|
+
create_table :table_name do |t|
|
159
|
+
t.string :column_name, validates: { length: { is: 3, allow_nil: true} }
|
160
|
+
end
|
99
161
|
end
|
100
162
|
```
|
101
163
|
|
102
164
|
```ruby
|
103
|
-
|
104
|
-
|
165
|
+
def up
|
166
|
+
change :table_name do |t|
|
167
|
+
t.change :column_name, :string, validates: { length: { is: 3 } }
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def down
|
172
|
+
change :table_name do |t|
|
173
|
+
t.change :column_name, :string, validates: { length: false }
|
174
|
+
end
|
105
175
|
end
|
106
176
|
```
|
107
177
|
|
108
178
|
simplifications (version >= 2.1 is required):
|
109
179
|
|
110
180
|
```ruby
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
181
|
+
def change
|
182
|
+
create_table :table_name do |t|
|
183
|
+
t.string :string_3, length: 3
|
184
|
+
t.string :string_from_1_to_3, length: 1..3,
|
185
|
+
t.string :string_1_or_3, length: [1, 3]
|
186
|
+
t.string :string_4, validates: { length: 4 }
|
187
|
+
t.string :string_4_in_trigger: length: { is: 4, as: :trigger }
|
188
|
+
end
|
117
189
|
end
|
118
190
|
```
|
119
191
|
|
@@ -141,39 +213,63 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
141
213
|
valid values array:
|
142
214
|
|
143
215
|
```ruby
|
144
|
-
|
216
|
+
def up
|
217
|
+
validates :table_name, :column_name, inclusion: { in: [1, 2, 3] }
|
218
|
+
end
|
219
|
+
|
220
|
+
def down
|
221
|
+
validates :table_name, :column_name, inclusion: false
|
222
|
+
end
|
145
223
|
```
|
146
224
|
|
147
225
|
with failure message specified:
|
148
226
|
|
149
227
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
228
|
+
def up
|
229
|
+
validates :table_name, :column_name,
|
230
|
+
inclusion: { in: [1, 2, 3],
|
231
|
+
message: "Column value should be equal to 1 or 2 or 3" }
|
232
|
+
end
|
233
|
+
|
234
|
+
def down
|
235
|
+
validates :table_name, :column_name, inclusion: false
|
236
|
+
end
|
153
237
|
```
|
154
238
|
|
155
239
|
all above are available in a create and change table blocks:
|
156
240
|
|
157
241
|
```ruby
|
158
|
-
|
159
|
-
|
242
|
+
def change
|
243
|
+
create_table :table_name do |t|
|
244
|
+
t.integer :column_name, validates: { inclusion: { in: 1..3 } }
|
245
|
+
end
|
160
246
|
end
|
161
247
|
```
|
162
248
|
|
163
249
|
```ruby
|
164
|
-
|
165
|
-
|
250
|
+
def up
|
251
|
+
change :table_name do |t|
|
252
|
+
t.change :column_name, :integer, validates: { inclusion: { in: 1..3 } }
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def down
|
257
|
+
change :table_name do |t|
|
258
|
+
t.change :column_name, :integer, validates: { inclusion: false }
|
259
|
+
end
|
166
260
|
end
|
167
261
|
```
|
168
262
|
|
169
263
|
simplifications (version >= 2.1 is required):
|
170
264
|
|
171
265
|
```ruby
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
266
|
+
def change
|
267
|
+
create_table :table_name do |t|
|
268
|
+
t.string :str_or_str_1, inclusion: ['str', 'str1']
|
269
|
+
t.string :from_str_to_str_1, inclusion: 'str'..'str1'
|
270
|
+
t.string :str_or_str_1_in_trigger, inclusion: { in: ['str', 'str1'],
|
271
|
+
as: :trigger}
|
272
|
+
end
|
177
273
|
end
|
178
274
|
```
|
179
275
|
|
@@ -196,40 +292,64 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
196
292
|
exclude 1, 2, and 3:
|
197
293
|
|
198
294
|
```ruby
|
199
|
-
|
295
|
+
def up
|
296
|
+
validates :table_name, :column_name, exclusion: { in: [1, 2, 3] }
|
297
|
+
end
|
298
|
+
|
299
|
+
def down
|
300
|
+
validates :table_name, :column_name, exclusion: false
|
301
|
+
end
|
200
302
|
```
|
201
303
|
|
202
304
|
the same with failure message:
|
203
305
|
|
204
306
|
```ruby
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
307
|
+
def up
|
308
|
+
validates :table_name, :column_name,
|
309
|
+
exclusion: {
|
310
|
+
in: [1, 2, 3],
|
311
|
+
message: "Column 'column_name' should not be equal to 1 or 2 or 3" }
|
312
|
+
end
|
313
|
+
|
314
|
+
def down
|
315
|
+
validates :table_name, :column_name, exclusion: false
|
316
|
+
end
|
209
317
|
```
|
210
318
|
|
211
319
|
all above are available in a create and change table blocks:
|
212
320
|
|
213
321
|
```ruby
|
214
|
-
|
215
|
-
|
322
|
+
def change
|
323
|
+
create_table :table_name do |t|
|
324
|
+
t.integer :column_name, validates: { exclusion: { in: 1..3 } }
|
325
|
+
end
|
216
326
|
end
|
217
327
|
```
|
218
328
|
|
219
329
|
```ruby
|
220
|
-
|
221
|
-
|
330
|
+
def up
|
331
|
+
change :table_name do |t|
|
332
|
+
t.change :column_name, :integer, validates: { exclusion: { in: 1..3 } }
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def down
|
337
|
+
change :table_name do |t|
|
338
|
+
t.change :column_name, :integer, validates: { exclusion: false }
|
339
|
+
end
|
222
340
|
end
|
223
341
|
```
|
224
342
|
|
225
343
|
simplifications (version >= 2.1 is required):
|
226
344
|
|
227
345
|
```ruby
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
346
|
+
def change
|
347
|
+
create_table :table_name do |t|
|
348
|
+
t.string :neither_str_nor_str_1, exclusion: ['str', 'str1']
|
349
|
+
t.string :from_str_to_str_1, exclusion: 'str'..'str1'
|
350
|
+
t.string :str_or_str_1_in_trigger, exclusion: { in: ['str', 'str1'],
|
351
|
+
as: :trigger}
|
352
|
+
end
|
233
353
|
end
|
234
354
|
```
|
235
355
|
|
@@ -249,45 +369,75 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
249
369
|
Examples:
|
250
370
|
|
251
371
|
```ruby
|
252
|
-
|
372
|
+
def up
|
373
|
+
validates :table_name, :column_name, presence: true
|
374
|
+
end
|
375
|
+
|
376
|
+
def down
|
377
|
+
validates :table_name, :column_name, presence: false
|
378
|
+
end
|
253
379
|
```
|
254
380
|
|
255
381
|
with failure message:
|
256
382
|
|
257
383
|
```ruby
|
258
|
-
|
259
|
-
|
384
|
+
def up
|
385
|
+
validates :table_name, :column_name,
|
386
|
+
presence: { message: 'value should not be empty' }
|
387
|
+
end
|
388
|
+
|
389
|
+
def down
|
390
|
+
validates :table_name, :column_name, presence: false
|
391
|
+
end
|
260
392
|
```
|
261
393
|
|
262
394
|
check when record is inserted only:
|
263
395
|
|
264
396
|
```ruby
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
397
|
+
def up
|
398
|
+
validates :table_name, :column_name,
|
399
|
+
presence: { message: 'value should not be empty',
|
400
|
+
as: :trigger,
|
401
|
+
on: :create }
|
402
|
+
end
|
403
|
+
|
404
|
+
def down
|
405
|
+
validates :table_name, :column_name, presence: false
|
406
|
+
end
|
269
407
|
```
|
270
408
|
|
271
409
|
all above are available in a create and change table blocks:
|
272
410
|
|
273
411
|
```ruby
|
274
|
-
|
275
|
-
|
412
|
+
def change
|
413
|
+
create_table :table_name do |t|
|
414
|
+
t.string :column_name, validates: { presence: true }
|
415
|
+
end
|
276
416
|
end
|
277
417
|
```
|
278
418
|
|
279
419
|
```ruby
|
280
|
-
|
281
|
-
|
420
|
+
def up
|
421
|
+
change :table_name do |t|
|
422
|
+
t.change :column_name, :string, validates: { presence: true }
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
def down
|
427
|
+
change :table_name do |t|
|
428
|
+
t.change :column_name, :string, validates: { presence: false }
|
429
|
+
end
|
282
430
|
end
|
283
431
|
```
|
284
432
|
|
285
433
|
simplifications (version >= 2.1 is required):
|
286
434
|
|
287
435
|
```ruby
|
288
|
-
|
289
|
-
|
290
|
-
|
436
|
+
def change
|
437
|
+
create_table :table_name do |t|
|
438
|
+
t.string :presence_in_check, presence: true
|
439
|
+
t.string :presence_in_trigger, presence: { as: :trigger, on: :create }
|
440
|
+
end
|
291
441
|
end
|
292
442
|
```
|
293
443
|
|
@@ -306,117 +456,203 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
306
456
|
Examples:
|
307
457
|
|
308
458
|
```ruby
|
309
|
-
|
459
|
+
def up
|
460
|
+
validates :table_name, :column_name, absence: true
|
461
|
+
end
|
462
|
+
|
463
|
+
def down
|
464
|
+
validates :table_name, :column_name, absence: false
|
465
|
+
end
|
310
466
|
```
|
311
467
|
|
312
468
|
with failure message:
|
313
469
|
|
314
470
|
```ruby
|
315
|
-
|
316
|
-
|
471
|
+
def up
|
472
|
+
validates :table_name, :column_name,
|
473
|
+
absence: { message: 'value should be empty' }
|
474
|
+
end
|
475
|
+
|
476
|
+
def down
|
477
|
+
validates :table_name, :column_name, absence: false
|
478
|
+
end
|
317
479
|
```
|
318
480
|
|
319
481
|
check when record is inserted only:
|
320
482
|
|
321
483
|
```ruby
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
484
|
+
def up
|
485
|
+
validates :table_name, :column_name,
|
486
|
+
absence: { message: 'value should be empty',
|
487
|
+
as: :trigger,
|
488
|
+
on: :create }
|
489
|
+
end
|
490
|
+
|
491
|
+
def down
|
492
|
+
validates :table_name, :column_name, absence: false
|
493
|
+
end
|
326
494
|
```
|
327
495
|
|
328
496
|
all above are available in a create and change table blocks:
|
329
497
|
|
330
498
|
```ruby
|
331
|
-
|
332
|
-
|
499
|
+
def change
|
500
|
+
create_table :table_name do |t|
|
501
|
+
t.string :column_name, validates: { absence: true }
|
502
|
+
end
|
333
503
|
end
|
334
504
|
```
|
335
505
|
|
336
506
|
```ruby
|
337
|
-
|
338
|
-
|
507
|
+
def up
|
508
|
+
change :table_name do |t|
|
509
|
+
t.change :column_name, :string, validates: { absence: true }
|
510
|
+
end
|
511
|
+
end
|
512
|
+
|
513
|
+
def down
|
514
|
+
change :table_name do |t|
|
515
|
+
t.change :column_name, :string, validates: { absence: false }
|
516
|
+
end
|
339
517
|
end
|
340
518
|
```
|
341
519
|
|
342
520
|
simplifications (version >= 2.1 is required):
|
343
521
|
|
344
522
|
```ruby
|
345
|
-
|
346
|
-
|
347
|
-
|
523
|
+
def change
|
524
|
+
create_table :table_name do |t|
|
525
|
+
t.string :absence_in_check, absence: true
|
526
|
+
t.string :absence_in_trigger, absence: { as: :trigger, on: :create }
|
527
|
+
end
|
348
528
|
end
|
349
529
|
```
|
350
530
|
|
351
|
-
|
531
|
+
Options:
|
532
|
+
|
533
|
+
* `message` - message that should be shown if validation failed
|
534
|
+
* `on` - validation event. Possible values `[:save, :update, :create]`. Ignored unless `:as == :trigger`. Default value: `:save`
|
535
|
+
* `create_tigger_name` - Name of the 'before insert' trigger that will be created if `:as == :trigger` && `:on` in `[:save, :create]`
|
536
|
+
* `update_tigger_name` - Name of the 'before update' trigger that will be created if `:as == :trigger` && `:on` in `[:save, :update]`
|
537
|
+
* `allow_nil` - ignore validation for `nil` values. Default value: `true`
|
538
|
+
* `allow_blank` - ignore validation for blank values. Default value: `true`
|
539
|
+
* `as` - defines the way how constraint will be implemented. Possible values: `[:trigger]` Default value: `:trigger`
|
540
|
+
|
541
|
+
### custom
|
542
|
+
|
543
|
+
(version >= 2.1 is required)
|
352
544
|
|
353
545
|
Examples:
|
354
546
|
|
355
547
|
allows only values that equals 'word' when trimmed:
|
356
548
|
|
357
549
|
```ruby
|
358
|
-
|
550
|
+
def up
|
551
|
+
validates :table_name, :column_name,
|
359
552
|
custom: { statement: "TRIM({column_name}) = 'word'" }
|
553
|
+
end
|
554
|
+
|
555
|
+
def down
|
556
|
+
validates :table_name, :column_name, custom: false
|
557
|
+
end
|
360
558
|
```
|
361
559
|
|
362
560
|
with failure message:
|
363
561
|
|
364
562
|
```ruby
|
365
|
-
|
366
|
-
|
367
|
-
|
563
|
+
def up
|
564
|
+
validates :table_name, :column_name,
|
565
|
+
custom: { statement: "TRIM({column_name}) = 'word'",
|
566
|
+
message: 'Column_name value should contain start word' }
|
567
|
+
end
|
568
|
+
|
569
|
+
def down
|
570
|
+
validates :table_name, :column_name, custom: false
|
571
|
+
end
|
368
572
|
```
|
369
573
|
|
370
574
|
implemented as trigger on insert event:
|
371
575
|
|
372
576
|
```ruby
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
577
|
+
def up
|
578
|
+
validates :table_name, :column_name,
|
579
|
+
custom: { statement: "TRIM({column_name}) = 'word'",
|
580
|
+
message: 'Column_name value should contain start word',
|
581
|
+
as: :trigger,
|
582
|
+
on: :create }
|
583
|
+
end
|
584
|
+
|
585
|
+
def down
|
586
|
+
validates :table_name, :column_name, custom: false
|
587
|
+
end
|
378
588
|
```
|
379
589
|
|
380
590
|
all above are available in a create and change table blocks:
|
381
591
|
|
382
592
|
```ruby
|
383
|
-
|
384
|
-
|
593
|
+
def change
|
594
|
+
create_table :table_name do |t|
|
595
|
+
t.string :column_name,
|
385
596
|
validates: { custom: { statement: "TRIM({column_name}) = 'word'"} }
|
597
|
+
end
|
386
598
|
end
|
387
599
|
```
|
388
600
|
|
389
601
|
```ruby
|
390
|
-
|
391
|
-
|
602
|
+
def up
|
603
|
+
change :table_name do |t|
|
604
|
+
t.change :column_name, :string,
|
392
605
|
validates: { custom: { statement: "TRIM({column_name}) = 'word'"} }
|
606
|
+
end
|
607
|
+
end
|
608
|
+
|
609
|
+
def down
|
610
|
+
change :table_name do |t|
|
611
|
+
t.change :column_name, :string, validates: { custom: false }
|
612
|
+
end
|
393
613
|
end
|
394
614
|
```
|
395
615
|
|
396
616
|
simplifications (version >= 2.1 is required):
|
397
617
|
|
398
618
|
```ruby
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
619
|
+
def change
|
620
|
+
create_table :table_name do |t|
|
621
|
+
t.string :contains_word, custom: "TRIM({contains_word}) = 'word'"
|
622
|
+
t.string :contains_word_synonym,
|
623
|
+
validates: "TRIM({contains_word_synonym}) = 'word'"
|
624
|
+
t.string :contains_word_in_trigger,
|
625
|
+
custom: { statement: "TRIM({contains_word_in_trigger}) = 'word'", as: :trigger }
|
626
|
+
end
|
405
627
|
end
|
406
628
|
```
|
407
629
|
|
408
630
|
Options:
|
409
631
|
|
410
632
|
* `:message` - message that should be shown if validation failed
|
411
|
-
|
412
|
-
* `:create_tigger_name` -
|
413
|
-
* `:update_tigger_name` -
|
414
|
-
* `:allow_nil` - ignore validation for
|
633
|
+
`:on` validation event. Possible values `[:save, :update, :create]`. Default value: `:save`
|
634
|
+
* `:create_tigger_name` - name of the 'before insert' trigger
|
635
|
+
* `:update_tigger_name` - name of the 'before update' trigger
|
636
|
+
* `:allow_nil` - ignore validation for nil values. Default value: false
|
415
637
|
* `:allow_blank` - ignore validation for blank values. Default value: `false`
|
416
638
|
* `:as` - defines the way how constraint will be implemented. Possible values: `[:trigger]`
|
639
|
+
|
640
|
+
## Version History
|
641
|
+
|
642
|
+
**(2.0.0)** (17 Jan, 2015)
|
643
|
+
|
644
|
+
* Completely rewritten. Migrated to Ruby 2.0 and RoR 4
|
645
|
+
|
646
|
+
**(2.1.0)** (22 Jan, 2015)
|
647
|
+
|
648
|
+
* Custom validation
|
649
|
+
|
650
|
+
**(2.2.0)** (28 Jan, 2015)
|
651
|
+
|
652
|
+
* Integration with ActiveRecord
|
653
|
+
|
654
|
+
## Contributing
|
417
655
|
|
418
|
-
## Contributing to mv-sqlite
|
419
|
-
|
420
656
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
421
657
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
422
658
|
* Fork the project
|
@@ -425,9 +661,4 @@ mv-sqlite is the SQLite driver for Migration Validators project (details here: h
|
|
425
661
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
426
662
|
* 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.
|
427
663
|
|
428
|
-
## Copyright
|
429
|
-
|
430
|
-
Copyright (c) 2015 Valeriy Prokopchuk. See LICENSE.txt for
|
431
|
-
further details.
|
432
|
-
|
433
664
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mv-sqlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valeriy Prokopchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2.
|
47
|
+
version: '2.2'
|
48
48
|
type: :runtime
|
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: '2.
|
54
|
+
version: '2.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jeweler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
144
144
|
- - '>='
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version: '0'
|
146
|
+
version: '2.0'
|
147
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - '>='
|