activerecord-databasevalidations 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 759df661c99bd799d77eeeb2917d9d892d22de04
4
- data.tar.gz: d2880441b78e568c1b7f6649158786dd84ceee1d
3
+ metadata.gz: c54c89523b089da35cf81ac327720dc7747477e4
4
+ data.tar.gz: b6c0284892866070449337290b70c5f481bc1c6b
5
5
  SHA512:
6
- metadata.gz: 65b73884f526c3bda96b3ea7e4a56ba9c520ad26d33cbefd70dd59e3244ad6963dac22ff82c86f7449f58f72b0cfcfde0b798ca34f3905be747bce56f74925ac
7
- data.tar.gz: 6a54b91564ece55439ce503e46c963a22090e14c170e29528bd1dc5fce0802d66b8ba36e908e7be2b8cc96e54f5da0520a10f680ff5876a5038d6a20a0d4640c
6
+ metadata.gz: fa9279114bf9c478f74f52c6753ae91d4829fdf0ba4e076d20981a6c057b016da7de4dad5598ea7a541d3dcfb31d44e93017fe8fe7bbed9fa923b55c21677f2e
7
+ data.tar.gz: 8efe103e02f9fdceaea9aea6e8094b9b7a224d605f30eacfad0dffb08221ba48394e96c3adbabea5679d626a0d9d15c01fa0471b0240ebfb95f7d5c4fc5a2beb
data/README.md CHANGED
@@ -38,6 +38,7 @@ You can also use `validates_database_constraints_of`:
38
38
  class Bar < ActiveRecord::Base
39
39
  validates_database_constraints_of :my_field, with: :size
40
40
  end
41
+ ```
41
42
 
42
43
  ### Available validations
43
44
 
@@ -66,8 +67,6 @@ end
66
67
  Note that this will create validations without inspecting the column to see if it
67
68
  actually makes sense.
68
69
 
69
- ```
70
-
71
70
  ## Contributing
72
71
 
73
72
  1. Fork it (http://github.com/wvanbergen/activerecord-databasevalidations/fork)
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "activerecord", "~> 4.0"
22
+ spec.add_runtime_dependency "rejectu"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.5"
24
25
  spec.add_development_dependency "rake"
@@ -1,3 +1,5 @@
1
+ require 'rejectu/rejectu'
2
+
1
3
  module ActiveModel
2
4
  module Validations
3
5
  class BasicMultilingualPlaneValidator < ActiveModel::EachValidator
@@ -5,7 +7,9 @@ module ActiveModel
5
7
 
6
8
  def validate_each(record, attribute, value)
7
9
  return if value.nil?
8
- if value.to_s.index(OUTSIDE_BMP)
10
+ return if value.to_s.encoding != Encoding::UTF_8
11
+
12
+ unless Rejectu.valid?(value.to_s)
9
13
  errors_options = options.except(:characters_outside_basic_multilingual_plane)
10
14
  default_message = options[:characters_outside_basic_multilingual_plane]
11
15
  errors_options[:message] ||= default_message if default_message
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module DatabaseValidations
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -30,4 +30,14 @@ class BasicMultilingualPlaneValidatorTest < Minitest::Test
30
30
  @model.unicode = nil
31
31
  assert @model.valid?
32
32
  end
33
+
34
+ def test_different_type
35
+ @model.unicode = 1
36
+ assert @model.valid?
37
+ end
38
+
39
+ def test_non_unicode_encoding
40
+ @model.unicode = 'ü'.encode('ISO-8859-15')
41
+ assert @model.valid?
42
+ end
33
43
  end
metadata CHANGED
@@ -1,83 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-databasevalidations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
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
26
  version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rejectu
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ~>
45
+ - - "~>"
32
46
  - !ruby/object:Gem::Version
33
47
  version: '1.5'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ~>
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.5'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: mysql2
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  description: Opt-in validations for your ActiveRecord models based on your MySQL database
@@ -88,8 +102,8 @@ executables: []
88
102
  extensions: []
89
103
  extra_rdoc_files: []
90
104
  files:
91
- - .gitignore
92
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".travis.yml"
93
107
  - Gemfile
94
108
  - Gemfile.activerecord40
95
109
  - Gemfile.activerecord41
@@ -123,17 +137,17 @@ require_paths:
123
137
  - lib
124
138
  required_ruby_version: !ruby/object:Gem::Requirement
125
139
  requirements:
126
- - - '>='
140
+ - - ">="
127
141
  - !ruby/object:Gem::Version
128
142
  version: '0'
129
143
  required_rubygems_version: !ruby/object:Gem::Requirement
130
144
  requirements:
131
- - - '>='
145
+ - - ">="
132
146
  - !ruby/object:Gem::Version
133
147
  version: '0'
134
148
  requirements: []
135
149
  rubyforge_project:
136
- rubygems_version: 2.0.14
150
+ rubygems_version: 2.2.2
137
151
  signing_key:
138
152
  specification_version: 4
139
153
  summary: Add validations to your ActiveRecord models based on MySQL database constraints.