activemodel-csv_validator 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/activemodel-csv_validator.gemspec +2 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/lib/activemodel/csv_validator/version.rb +1 -1
- data/lib/activemodel/validations/csv_validator.rb +7 -1
- metadata +7 -7
- data/Gemfile.lock +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb70efb8db9417e97271234408c30226f68d3762f6bead02ad62d32a35ab3174
|
4
|
+
data.tar.gz: a0f5e957d47de6f6a267df40cfeb43c42b95a68026ec66912d40aaf714babdee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3082350fdb33f663589223f7de9530bdb39d0195d5da153ec014c552cb437227330aed4324080021fb7c90363590b48dbdf1bcdb9b39e5f927d9fdeb58657db
|
7
|
+
data.tar.gz: 7adad3526afda27bb99ef778bfb779c6abd58b477d76c2f078c9df5199dc8f3706eafa801f88326476e7cce2686d04467fdcc71db87545cb099f621b17e8145b
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
+
spec.required_ruby_version = '>= 2.6.0'
|
25
26
|
spec.add_dependency "activemodel", ">= 5.2.0"
|
26
27
|
spec.add_dependency "activesupport", ">= 5.2.0"
|
27
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
31
|
end
|
data/config/locales/en.yml
CHANGED
data/config/locales/ja.yml
CHANGED
@@ -6,11 +6,17 @@ module ActiveModel
|
|
6
6
|
module Validations
|
7
7
|
class CsvValidator < ActiveModel::EachValidator
|
8
8
|
def validate_each(record, attribute, value)
|
9
|
+
return if value.nil?
|
10
|
+
|
9
11
|
content = NKF.nkf('-w', File.read(value.path, universal_newline: true))
|
10
12
|
rows = CSV.parse(content, headers: :first_row, converters: :integer)
|
11
13
|
|
12
14
|
if options[:max].present? && rows.size > options[:max]
|
13
|
-
record.errors.add(attribute, :max_rows, options.slice(:max).merge(rows: rows.size))
|
15
|
+
record.errors.add(attribute, :max_rows, **options.slice(:max).merge(rows: rows.size))
|
16
|
+
end
|
17
|
+
|
18
|
+
if options[:min].present? && rows.size < options[:min]
|
19
|
+
record.errors.add(attribute, :min_rows, **options.slice(:min).merge(rows: rows.size))
|
14
20
|
end
|
15
21
|
|
16
22
|
if options[:headers].present?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-csv_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,9 +90,9 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- CODE_OF_CONDUCT.md
|
94
95
|
- Gemfile
|
95
|
-
- Gemfile.lock
|
96
96
|
- LICENSE.txt
|
97
97
|
- README.md
|
98
98
|
- Rakefile
|
@@ -116,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
119
|
+
version: 2.6.0
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.1.2
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: CSV Validator for Active Model
|
data/Gemfile.lock
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
activemodel-csv_validator (0.1.0)
|
5
|
-
activemodel (>= 5.2.0)
|
6
|
-
activesupport (>= 5.2.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activemodel (6.0.1)
|
12
|
-
activesupport (= 6.0.1)
|
13
|
-
activesupport (6.0.1)
|
14
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (>= 0.7, < 2)
|
16
|
-
minitest (~> 5.1)
|
17
|
-
tzinfo (~> 1.1)
|
18
|
-
zeitwerk (~> 2.2)
|
19
|
-
concurrent-ruby (1.1.5)
|
20
|
-
diff-lcs (1.3)
|
21
|
-
i18n (1.7.0)
|
22
|
-
concurrent-ruby (~> 1.0)
|
23
|
-
minitest (5.13.0)
|
24
|
-
rake (10.5.0)
|
25
|
-
rspec (3.9.0)
|
26
|
-
rspec-core (~> 3.9.0)
|
27
|
-
rspec-expectations (~> 3.9.0)
|
28
|
-
rspec-mocks (~> 3.9.0)
|
29
|
-
rspec-core (3.9.0)
|
30
|
-
rspec-support (~> 3.9.0)
|
31
|
-
rspec-expectations (3.9.0)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.9.0)
|
34
|
-
rspec-mocks (3.9.0)
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.9.0)
|
37
|
-
rspec-support (3.9.0)
|
38
|
-
thread_safe (0.3.6)
|
39
|
-
tzinfo (1.2.5)
|
40
|
-
thread_safe (~> 0.1)
|
41
|
-
zeitwerk (2.2.1)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
activemodel-csv_validator!
|
48
|
-
bundler (~> 2.0)
|
49
|
-
rake (~> 10.0)
|
50
|
-
rspec (~> 3.0)
|
51
|
-
|
52
|
-
BUNDLED WITH
|
53
|
-
2.0.2
|