validates_by_schema 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -1
- data/lib/validates_by_schema.rb +4 -0
- data/lib/validates_by_schema/validation_option.rb +5 -1
- data/lib/validates_by_schema/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69129acef7a43c707e98663657e97dc1b7222ce1
|
4
|
+
data.tar.gz: 4368f63d8423b026079cea4fd215baf7c27791a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1df6f34e85a82ca55287847596878ce45a3d3d8e076cfe7b150919769090f26ad94d68e92d9aaf0dfd9eced591d0bda74f602a5706b05041dc24a907be4e4a2
|
7
|
+
data.tar.gz: a391c996e1f204c10d3d622f8c7f9d15a8ecf1640e44078a09a8f07d8c351338dcb80515bdc8a6417f1baa069703d5ad04f42fc93eb800fd64d81dcbd1119d27
|
data/Rakefile
CHANGED
@@ -33,9 +33,20 @@ task default: :spec
|
|
33
33
|
|
34
34
|
|
35
35
|
namespace :db do
|
36
|
+
task :drop do
|
37
|
+
puts "dropping"
|
38
|
+
case ENV['DB']
|
39
|
+
when 'postgresql'
|
40
|
+
exec "psql -c 'drop database if exists validates_by_schema_test;' -U postgres"
|
41
|
+
when 'mysql'
|
42
|
+
exec "mysql -e 'drop database if exists validates_by_schema_test;'"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
36
46
|
task :create do
|
47
|
+
puts "creating"
|
37
48
|
case ENV['DB']
|
38
|
-
when'postgresql'
|
49
|
+
when 'postgresql'
|
39
50
|
exec "psql -c 'create database validates_by_schema_test;' -U postgres"
|
40
51
|
when 'mysql'
|
41
52
|
exec "mysql -e 'create database validates_by_schema_test;'"
|
data/lib/validates_by_schema.rb
CHANGED
@@ -11,6 +11,10 @@ module ValidatesBySchema
|
|
11
11
|
customized_columns(options).each do |c|
|
12
12
|
ValidationOption.new(self, c).define!
|
13
13
|
end
|
14
|
+
|
15
|
+
rescue ::ActiveRecord::NoDatabaseError
|
16
|
+
# Since `db:create` and other tasks from Rails 5.2.0 might load models,
|
17
|
+
# we need to swallow this error to execute `db:create` properly.
|
14
18
|
end
|
15
19
|
|
16
20
|
private
|
@@ -51,8 +51,12 @@ class ValidatesBySchema::ValidationOption
|
|
51
51
|
numericality
|
52
52
|
end
|
53
53
|
|
54
|
+
def array?
|
55
|
+
column.respond_to?(:array) && column.array
|
56
|
+
end
|
57
|
+
|
54
58
|
def length?
|
55
|
-
[:string, :text].include?(column.type) && column.limit
|
59
|
+
[:string, :text].include?(column.type) && column.limit && !array?
|
56
60
|
end
|
57
61
|
|
58
62
|
def length
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_by_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lewis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -57,16 +57,16 @@ dependencies:
|
|
57
57
|
name: shoulda-matchers
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
62
|
+
version: '3.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "<"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
69
|
+
version: '3.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sqlite3
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.4.
|
147
|
+
rubygems_version: 2.4.8
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Automatic validation based on your database schema column types and limits.
|