mini_form 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -1
- data/lib/mini_form/errors.rb +2 -1
- data/lib/mini_form/nested_validator.rb +9 -0
- data/lib/mini_form/version.rb +1 -1
- data/mini_form.gemspec +2 -2
- data/spec/mini_form_spec.rb +4 -0
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fae1bbe2eb9f254e0315e13364a0d9a19a87515061f066a37fd89689be9c657
|
4
|
+
data.tar.gz: 34c5ac1537cf058c0c67cdaa7ef4c88dd7aaaef63412cbabddbad5e13be73435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada501cc629ff6fd8701162248d095868bf2a7a9ac0e7e23f74caae5d08d1f8cbd31d9202fd47f52283cbb3117cd8c0d1a2705b9c074a09a6c95cb622ac2e4ee
|
7
|
+
data.tar.gz: 8cb38e2bf06594be100078b2d2b0ee10c4d5a356808ba4249fc2f63f060478619c97dc8d776004d20c5f52cb2b1dfef5b93099ca9307379c7921006a40bfa0ee
|
data/CHANGELOG.md
CHANGED
data/lib/mini_form/errors.rb
CHANGED
@@ -5,7 +5,8 @@ module MiniForm
|
|
5
5
|
def initialize(object)
|
6
6
|
@errors = object.errors
|
7
7
|
|
8
|
-
|
8
|
+
arr_obj = errors.respond_to?(:attribute_names) ? errors.attribute_names : errors.keys
|
9
|
+
super "Form validation failed for: #{arr_obj.join(', ')}"
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -5,6 +5,15 @@ module MiniForm
|
|
5
5
|
def validate_each(record, _, relation)
|
6
6
|
return if relation.valid?
|
7
7
|
|
8
|
+
if record.errors.respond_to?(:merge!)
|
9
|
+
# Rails 6.1+ where accessing ActiveModel::Errors as a hash has been
|
10
|
+
# deprecated and the errors array is frozen. For this reason we use the new
|
11
|
+
# method merge!() which appends the errors as NestedErrors to the array. "This is the way."
|
12
|
+
record.errors.merge!(relation.errors)
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
# Rails < 6.1
|
8
17
|
relation.errors.each do |name, value|
|
9
18
|
record.errors.add name, value
|
10
19
|
end
|
data/lib/mini_form/version.rb
CHANGED
data/mini_form.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'activemodel', '>= 4.0'
|
22
22
|
|
23
|
-
spec.add_development_dependency 'bundler', '
|
24
|
-
spec.add_development_dependency 'rake', '
|
23
|
+
spec.add_development_dependency 'bundler', '>= 2.1.4'
|
24
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
26
26
|
spec.add_development_dependency 'rspec-mocks', '>= 2.12.3'
|
27
27
|
spec.add_development_dependency 'coveralls'
|
data/spec/mini_form_spec.rb
CHANGED
@@ -51,6 +51,10 @@ module MiniForm
|
|
51
51
|
expect(value).to eq(expected_value), message
|
52
52
|
end
|
53
53
|
|
54
|
+
def assert_respond_to(klass, method, message = nil)
|
55
|
+
expect(klass).to respond_to(method), message
|
56
|
+
end
|
57
|
+
|
54
58
|
ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |method|
|
55
59
|
example(method.gsub('_', ' ')) { send method }
|
56
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Radoslav Stankov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.4
|
34
34
|
type: :development
|
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:
|
40
|
+
version: 2.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
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:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ homepage: https://github.com/RStankov/MiniForm
|
|
152
152
|
licenses:
|
153
153
|
- MIT
|
154
154
|
metadata: {}
|
155
|
-
post_install_message:
|
155
|
+
post_install_message:
|
156
156
|
rdoc_options: []
|
157
157
|
require_paths:
|
158
158
|
- lib
|
@@ -167,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
171
|
-
|
172
|
-
signing_key:
|
170
|
+
rubygems_version: 3.1.4
|
171
|
+
signing_key:
|
173
172
|
specification_version: 4
|
174
173
|
summary: Easy to use form objects in Rails projects
|
175
174
|
test_files:
|