formify 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/formify/errors/form_error.rb +12 -0
- data/lib/formify/errors/validation_error.rb +16 -0
- data/lib/formify/form.rb +2 -2
- data/lib/formify/version.rb +1 -1
- data/lib/formify.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 070f0acf8fa985c539c0a758ebc8109c8346106b8b96d41ca59b54dbef027318
|
4
|
+
data.tar.gz: d4983fd2ac3c69e710745848e46a1d934056f96690e271931d15bd6395ddb31e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d86b66ddaa3a46fa0a761bd27cf1097d3071fbf38e7d9988c76e31a78a0dc78f4aec8de6710461d0acaf055acedafa4ec65083d207acde445c9f307dac656f
|
7
|
+
data.tar.gz: 2702552193584f18d3f40431724e7569c33e2ad95a59e250658a0a7eac94e9cfe2e0c818cefdc8b9997e2e7c63ea3c30e626f6b8977fb97de4df8c5e4f6769c5
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Formify
|
2
|
+
module Errors
|
3
|
+
class ValidationError < Formify::Errors::FormError
|
4
|
+
attr_reader :attribute
|
5
|
+
|
6
|
+
def initialize(form:)
|
7
|
+
@attribute = form.errors.first.first
|
8
|
+
|
9
|
+
super(
|
10
|
+
form: form,
|
11
|
+
message: form.errors.full_messages_for(@attribute).first
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/formify/form.rb
CHANGED
@@ -44,7 +44,7 @@ module Formify
|
|
44
44
|
def validate_or_fail(*instances)
|
45
45
|
unless valid?
|
46
46
|
return Resonad.Failure(
|
47
|
-
|
47
|
+
Formify::Errors::ValidationError.new(form: self)
|
48
48
|
)
|
49
49
|
end
|
50
50
|
|
@@ -53,7 +53,7 @@ module Formify
|
|
53
53
|
next if instance.valid?
|
54
54
|
|
55
55
|
return Resonad.Failure(
|
56
|
-
|
56
|
+
Formify::Errors::ValidationError.new(form: self, message: instance.full_messages.first)
|
57
57
|
)
|
58
58
|
end
|
59
59
|
end
|
data/lib/formify/version.rb
CHANGED
data/lib/formify.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Jackson
|
@@ -88,6 +88,8 @@ files:
|
|
88
88
|
- bin/setup
|
89
89
|
- formify.gemspec
|
90
90
|
- lib/formify.rb
|
91
|
+
- lib/formify/errors/form_error.rb
|
92
|
+
- lib/formify/errors/validation_error.rb
|
91
93
|
- lib/formify/form.rb
|
92
94
|
- lib/formify/spec_helpers.rb
|
93
95
|
- lib/formify/version.rb
|